VMware vSphere 6.0 WSDL API
我正在尝试检索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调用来检索数据中心群集?
答案 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
)
)
)
)
我不知道它是否有帮助,我只是希望如此!祝你好运。