VMware Cloud Community
rchopkar
Contributor
Contributor

How to get vsphere networks name with vCloud API?

I am using below vcloud API to get list of vsphere networks from vcenter, I get the list of all networks with their MoRef but the network name attribute is blank, however  I can see  names of the vsphere networks on vCloud UI.

API:

https://vcloud.example.com/api/admin/extension/vimServer/id/networks

Response:

<vmext:VimObjectRefList type="application/vnd.vmware.admin.vimServerNetworks+xml" xsi:schemaLocation="http://www.vmware.com/vcloud/extension/v1.5 http://example.com/api/v1.5/schema/vmwextensions.xsd http://www.vmware.com/vcloud/v1.5 http://example.com/api/v1.5/schema/master.xsd">

<vcloud:Link rel="up" href= "https://example.com/api/admin/extension/vimServer/fd4fe2c2-06eb-488f-a1c5-00b135d07d30" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>

<vmext:VimObjectRefs>

      <vmext:VimObjectRef>

        <vmext:VimServerRef href= "https://example.com/api/admin/extension/vimServer/fd4fe2c2-06eb-488f-a1c5-00b135d07d30" name="" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>

        <vmext:MoRef>dvportgroup-681</vmext:MoRef>

        <vmext:VimObjectType>DV_PORTGROUP</vmext:VimObjectType>

      </vmext:VimObjectRef>

    <vmext:VimObjectRef>

      <vmext:VimServerRef href= "https://example.com/api/admin/extension/vimServer/fd4fe2c2-06eb-488f-a1c5-00b135d07d30" name="" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>

      <vmext:MoRef>dvportgroup-48</vmext:MoRef>

      <vmext:VimObjectType>DV_PORTGROUP</vmext:VimObjectType>

    </vmext:VimObjectRef>

    <vmext:VimObjectRef>

      <vmext:VimServerRef href= "https://example.com/api/admin/extension/vimServer/fd4fe2c2-06eb-488f-a1c5-00b135d07d30" name="" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>

      <vmext:MoRef>network-121</vmext:MoRef>

      <vmext:VimObjectType>NETWORK</vmext:VimObjectType>

    </vmext:VimObjectRef>

  </vmext:VimObjectRefs>

</vmext:VimObjectRefList>

2 Replies
rchopkar
Contributor
Contributor

Thanks Jignesh for help,

You provided API return me the external Network types...

I got the solution:

GET https://<VCLOUD IP>/api/query?type=portgroup&format=records



<QueryResultRecords name="portgroup" page="1" pageSize="25" total="3" href="https://example.com/api/query?type=portgroup&page=1&pageSize=25&format=records"type="application/vnd.vmware.vcloud.query.records+xml"xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://example.com/api/v1.5/schema/master.xsd">

<Link rel="alternate" href= "https://example.com/api/query?type=portgroup&page=1&pageSize=25&format=idrecords"type="application/vnd.vmware.vcloud.query.idrecords+xml"/>

<PortgroupRecord isVCEnabled="true" moref="dvportgroup-48" name="DPortGroup1" networkName="--"portgroupType="DV_PORTGROUP" scopeType="-1"vc="https://example.com/api/admin/extension/vimServer/cea5a0c2-0835-468d-a8e0-2ed0a39a237b"vcName="Vcenter-with-API"/>

<PortgroupRecord isVCEnabled="true" moref="dvportgroup-681" name="test" networkName="--"portgroupType="DV_PORTGROUP" scopeType="-1"vc="https://example.com/api/admin/extension/vimServer/cea5a0c2-0835-468d-a8e0-2ed0a39a237b"vcName="Vcenter-with-API"/>

<PortgroupRecord isVCEnabled="true" moref="network-121" name="MGMT-LAN" networkName="--" portgroupType="NETWORK" scopeType="-1"vc="https://example.com/api/admin/extension/vimServer/cea5a0c2-0835-468d-a8e0-2ed0a39a237b"vcName="Vcenter-with-API"/>

</QueryResultRecords

>