douzong6649 2015-08-06 06:07
浏览 180

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

VMware vSphere 6.0 WSDL API

See documentation at: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.pg.doc/PG_Introduction_Inventory.6.4.html

I am trying to retrieve a list of datacenters in a VMware vCenter Inventory, and there is one datacenter present.

I have created a SOAP call in PHP as follows ($request is 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
                                )
                        )
                )
        )
)

I believe the [path] => datastoreFolder is incorrect, and VMware documentation shows datastoreFolder, hostFolder, networkFolder, and vmFolder. There are no datacenters in any of them, and any other object seems to break the SOAP call with an error.

Is there a way to retrieve the datacenters clusters using a soap call?

  • 写回答

1条回答 默认 最新

  • dotwc62080 2016-06-08 16:05
    关注

    I've been having the same problem. Then I took a closer look at this page:

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

    Quote:

    Every Datacenter has the following set of dedicated folders. These folders are empty until you create entities for the Datacenter.

    A folder for VirtualMachine, template, and VirtualApp objects. A folder for a ComputeResource hierarchy. A folder for Network, DistributedVirtualSwitch, and DistributedVirtualPortgroup objects. A folder for Datastore objects.

    You are using ResourcePool in your propSet, but that does not exists for a Datacenter.

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

    This is what I use to read all the hosts:

    [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
                        )
    
                )
    
        )
    

    )

    I don't know if it helps, I just hope so! Good luck.

    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入