VMware vCloud

 View Only
  • 1.  How can I get vApp or VM 's host IP by rest API

    Posted Jun 08, 2012 10:41 AM

    Hi guys

    I want to get vApp's host IP, I do not mean VM's IP, I mean the host which VM in.

    I try several rest api but can not get this information.

    I can see this information through web page, so I guess there must be a rest api which I can get this from.

    regards



  • 2.  RE: How can I get vApp or VM 's host IP by rest API

    Broadcom Employee
    Posted Jun 08, 2012 10:51 AM

    There're a couple of ways to achieve this using REST API. Basically this kind of information is only available to System administrators:

    1) Using query service: you can use the query named 'adminVM':

    GET <host>/api/query?type=adminVM

    This returns a list of AdminVMRecord objects with a 'hostName' property in them. This 'hostName' property contains the IP address of the ESX host on which the VM resides:

    <AdminVMRecord vmToolsVersion="6404" vdc="https://10.26.49.174/api/vdc/94964469-f3da-4f11-ae77-321f07421f83" vc="https://10.26.49.174/api/admin/extension/vimServer/e6136146-e097-42b6-a282-12d1967a92c5" status="POWERED_OFF" org="https://10.26.49.174/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" numberOfCpus="1" networkName="AutomationNetwork" name="TemplateNic" moref="vm-1504" memoryMB="32" isVdcEnabled="true" isVAppTemplate="true" isPublished="false" isDeployed="false" isDeleted="false" hostName="10.23.116.201" hardwareVersion="7" guestOs="Other (32-bit)" datastoreName="datastore1" containerName="TemplateNic" container="https://10.26.49.174/api/vAppTemplate/vappTemplate-9e540670-44e9-45a0-950d-1dae5b9d198b" catalogName="CatalogvappTemplate-9e540670-44e9-45a0-950d-1dae5b9d198b" href="https://10.26.49.174/api/vApp/vm-05f2a7c5-016b-4043-81dc-d217b4a6583f" pvdcHighestSupportedHardwareVersion="8" containerStatus="RESOLVED"/>

    2) Using the VCloudExtension element inside VM representation:

    GET <host>/api/vApp/vm-<uuid>

    This returns a <Vm> object with <VCloudExtension> element inside. It contains information about host, datastore and actual VM in vCenter. The drawback is that it returns the morefs (VC IDs) of these objects so you'll have to make another API call to resolve those IDs to IPs.

    <VCloudExtension required="false">

    <vmext:VmVimInfo>
    <vmext:VmVimObjectRef>
    <vmext:VimServerRef type="application/vnd.vmware.admin.vmwvirtualcenter+xml" name="ConfigWizard Configured vCenter" href="https://10.26.49.174/api/admin/extension/vimServer/e6136146-e097-42b6-a282-12d1967a92c5"/>
    <vmext:MoRef>vm-1504</vmext:MoRef>
    <vmext:VimObjectType>VIRTUAL_MACHINE</vmext:VimObjectType>
    </vmext:VmVimObjectRef>
    <vmext:DatastoreVimObjectRef>
    <vmext:VimServerRef type="application/vnd.vmware.admin.vmwvirtualcenter+xml" name="ConfigWizard Configured vCenter" href="https://10.26.49.174/api/admin/extension/vimServer/e6136146-e097-42b6-a282-12d1967a92c5"/>
    <vmext:MoRef>datastore-79</vmext:MoRef>
    <vmext:VimObjectType>DATASTORE</vmext:VimObjectType>
    </vmext:DatastoreVimObjectRef>
    <vmext:HostVimObjectRef>
    <vmext:VimServerRef type="application/vnd.vmware.admin.vmwvirtualcenter+xml" name="ConfigWizard Configured vCenter" href="https://10.26.49.174/api/admin/extension/vimServer/e6136146-e097-42b6-a282-12d1967a92c5"/>
    <vmext:MoRef>host-78</vmext:MoRef>
    <vmext:VimObjectType>HOST</vmext:VimObjectType>
    </vmext:HostVimObjectRef>
    <vmext:VirtualDisksMaxChainLength>2</vmext:VirtualDisksMaxChainLength>
    </vmext:VmVimInfo>
    </VCloudExtension>

    Regards,

    Todor Todorov



  • 3.  RE: How can I get vApp or VM 's host IP by rest API

    Posted Jul 04, 2013 09:04 AM

    Adding to the above question. Is there a way to assign a IP to a VM within a vApp using REST api. Since I am trying to automate few task including the assigning the VM IP within the vApps. If anyone could help me would be of great help..

    Thanks in advance

    Regards,

    Haroon



  • 4.  RE: How can I get vApp or VM 's host IP by rest API

    Broadcom Employee
    Posted Jul 10, 2013 03:20 PM

    There's an example at Update the NetworkConnectionSection of a Virtual Machine that might help.



  • 5.  RE: How can I get vApp or VM 's host IP by rest API

    Posted Nov 07, 2016 03:40 PM

    Hello,

    Does this solution requires vCloud Plugin to be installed?

    Regards,

    RA



  • 6.  RE: How can I get vApp or VM 's host IP by rest API

    Broadcom Employee
    Posted Nov 07, 2016 03:46 PM

    Not sure what plug-in you are referring to, but the procedure in Update the NetworkConnectionSection of a Virtual Machine does not require any plug-ins to be installed



  • 7.  RE: How can I get vApp or VM 's host IP by rest API

    Posted Nov 07, 2016 03:51 PM

    In the request and response of the API it mentioned vCloud, I highlighted below in red

    Request:

    PUT "https://vcloud.example.com/api/vApp/vm-4/networkConnectionSection/ Content-type: application/vnd.vmware.vcloud.networkConnectionSection+xml 

    Response:

    202 Accepted Content-Type: application/vnd.vmware.vcloud.task+xml ... <Task ... operation="Updating Virtual Application Linux FTP server (7)" ...> ...

    vCloud Air vSphere Client Plug-in lets you view and manage your vCloud Air resources in the vSphere Web Client

    I'm not sure if I have to install this plugin to run these APIs



  • 8.  RE: How can I get vApp or VM 's host IP by rest API

    Broadcom Employee
    Posted Nov 07, 2016 04:55 PM

    no plug-in is required



  • 9.  RE: How can I get vApp or VM 's host IP by rest API

    Posted Nov 08, 2016 03:37 PM

    Hi srmdocs,

    Need some more help from you.

    The link you provided is for vCloud Director, I don't have vCloud Director, We only have the vCenter and ESXi.

    Is there a way I can assign IP without vCloud Director?



  • 10.  RE: How can I get vApp or VM 's host IP by rest API

    Broadcom Employee
    Posted Nov 08, 2016 03:42 PM

    you need to install the vCloud Director product to use the vCloud API



  • 11.  RE: How can I get vApp or VM 's host IP by rest API

    Posted Nov 08, 2016 04:03 PM

    Ok thanks, is there any other way to assign static IP address without installing vCloud Director?