vsphere-automation-sdk-rest icon indicating copy to clipboard operation
vsphere-automation-sdk-rest copied to clipboard

Retrieving IPv4 address of deployed VM

Open WinstonJake opened this issue 4 years ago • 0 comments

Hi guys. My org is currently using vSphere 6.7. I don't foresee any plans of upgrade so far. When we deploy VM's in our org, the IPv4 address is set as an property under additional parameters in the request body of "https://{{vc}}/rest/com/vmware/vcenter/ovf/library-item/id:{{libraryitemID}}?~action=deploy" API. (please see the snippet below of the request body).

My question is, is there any way i can search vSphere client to retrieve VMs that are deployed on the same IP? is it possible to do a VM search based on, for example, "ip0" property in the below snippet? can i do a search by IP address using APIs? (i know this is possible using SDK, but needed it to work using APIs)

NOTE:

  1. https://{{vc}}/rest/vcenter/vm/vm-6768/guest/identity - This API returns only one IP, whereas i would need the entire list of IP addresses.
  2. I hear that the API to return ALL IP's was released in vSphere API version 7.0 but (i think) as i don't have that version, i get a 404 error.

SNIPPET: { "deployment_spec": { "additional_parameters":[ { "@class": "com.vmware.vcenter.ovf.property_params", "properties":[ { "instance_id": "xxxxx", "class_id": "vami", "description": "Network IPV4 address", "id": "ip0", "label": "Network IPV4 address", "category": "xxxxx", "type": "ip", "value": "{{IPv4Address}}", "ui_optional": false },

WinstonJake avatar Apr 25 '20 06:04 WinstonJake