如何配置vSphere 6 SOAP调用以显示资源池或数据中心?

时间:2015-08-06 06:07:52

标签: php soap wsdl vmware vsphere

VMware vSphere 6.0 WSDL API

请参阅以下文件: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.pg.doc/PG_Introduction_Inventory.6.4.html

我正在尝试检索VMware vCenter Inventory中的数据中心列表,并且存在一个数据中心。

我在PHP中创建了一个SOAP调用,如下所示($ request是print_r()ed):

stdClass Object(
        [_this] => stdClass Object(
            [_] => propertyCollector
            [type] => PropertyCollector
        )
    [specSet] => Array(
            [propSet] => Array(
                    [0] => Array(
                            [type] => ResourcePool
                            [all] => 1
                        )
                )
            [objectSet] => Array(
                    [obj] => stdClass Object(
                            [_] => group-d1
                            [type] => Folder
                        )
                    [skip] => 
                    [selectSet] => Array(
                            [0] => SoapVar Object(
                                    [enc_type] => 301
                                    [enc_value] => Array(
                                            [name] => FolderTraversalSpec
                                            [type] => Folder
                                            [path] => childEntity
                                            [skip] => 
                                            [0] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => FolderTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                            [1] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => DataCenterVMTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                        )
                                    [enc_stype] => TraversalSpec
                                )
                            [1] => SoapVar Object(
                                    [enc_type] => 301
                                    [enc_value] => Array(
                                            [name] => DataCenterVMTraversalSpec
                                            [type] => Datacenter
                                            [path] => datastoreFolder
                                            [skip] => 
                                            [0] => SoapVar Object(
                                                    [enc_type] => 301
                                                    [enc_value] => Array(
                                                            [name] => FolderTraversalSpec
                                                        )
                                                    [enc_name] => selectSet
                                                )
                                        )
                                    [enc_stype] => TraversalSpec
                                )
                        )
                )
        )
)

我相信[path] => datastoreFolder不正确,VMware文档显示了datastoreFolder,hostFolder,networkFolder和vmFolder。其中任何一个都没有数据中心,任何其他对象似乎都会错误地调用SOAP调用。

有没有办法使用soap调用来检索数据中心群集?

1 个答案:

答案 0 :(得分:0)

我一直有同样的问题。然后我仔细看了一下这个页面:

https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.Datacenter.html

引用:

  

每个数据中心都有以下一组专用文件夹。在为数据中心创建实体之前,这些文件夹是空的。

     

VirtualMachine,模板和VirtualApp对象的文件夹。   ComputeResource层次结构的文件夹。   Network,DistributedVirtualSwitch和DistributedVirtualPortgroup对象的文件夹。   数据存储区对象的文件夹。

您在propSet中使用ResourcePool,但数据中心不存在。

[propSet] => Array(
        [0] => Array(
                [type] => ResourcePool
                [all] => 1
            )
    )

这是我用来阅读所有主机的内容:

[propSet] => Array
    (
        [0] => Array
            (
                [type] => ComputeResource
                [all] => 1
            )
    )

[objectSet] => Array
    (
        [obj] => stdClass Object
            (
                [_] => group-d1
                [type] => Folder
            )

        [skip] => 
        [selectSet] => Array
            (
                [0] => SoapVar Object
                    (
                        [enc_type] => 301
                        [enc_value] => Array
                            (
                                [name] => FolderTraversalSpec
                                [type] => Folder
                                [path] => childEntity
                                [skip] => 
                                [0] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => FolderTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                                [1] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => DataCenterVMTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                            )

                        [enc_stype] => TraversalSpec
                    )

                [1] => SoapVar Object
                    (
                        [enc_type] => 301
                        [enc_value] => Array
                            (
                                [name] => DataCenterVMTraversalSpec
                                [type] => Datacenter
                                [path] => hostFolder
                                [skip] => 
                                [0] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => Array
                                            (
                                                [name] => FolderTraversalSpec
                                            )

                                        [enc_name] => selectSet
                                    )

                            )

                        [enc_stype] => TraversalSpec
                    )

            )

    )

我不知道它是否有帮助,我只是希望如此!祝你好运。