1

Is there a way to get the IPStack for a vm in vmware? Particularly using pyvmomi for python

https://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.vm.GuestInfo.html#field_detail no longer shows ip stack and vm.summary returns a large list of info including a single IP and each network card, but not which ip each card is connected to.

https://github.com/vmware/pyvmomi/issues/769 seems to show that at some point there was an output that included the IPStack.

I have MANY vms with more than one ip address viewable when you log into the vcenters via their html interface. Each IP is viewable, and using the mob, you can access

VIRTUALCENTERNAME/mob/?moid=vm%2dVM_NUMBER&doPath=guest%2eipStack I can see the info I want, but how can I pull this via python

Code snippet:

si = SmartConnectNoSSL(host=MY_VCENTER, user='MYUSERNAME',pwd=MYPASSWORD, port=MYPORT)
atexit.register(Disconnect, si)
content = si.RetrieveServiceContent()
container = content.rootFolder
recursive = True
viewTypeComputeResource = [vim.ComputeResource]
containerView = content.viewManager.CreateContainerView(container, viewTypeComputeResource, recursive)  # create container view
clusters = containerView.view
for cluster in clusters:
    hosts = cluster.host
    for each_host in hosts:
        vms = each_host.vm
        for vm in vms:
            print(vm.summary)

This code runs and gets you from the root folder to the vms and their summaries, which provide guest info, ethernet info etc. I would assume vm.summary.guestInfo (or varying caps and non caps) would help but didnt.

AlbinoRhino
  • 467
  • 6
  • 23

1 Answers1

1

There's a dependency on these VMs having VMware Tools installed and running, so first start by verifying that the VMs are powered on and have VMware Tools running.

After that, you should be able to retrieve that information from either:

  • vm.guest.ipAddress
  • vm.summary.guest.ipAddress
Kyle Ruddy
  • 1,886
  • 1
  • 7
  • 5