How to get ipaddress of a specific nic when retiring a vm?

our vms have 2 or 3 nics.

when provisionning, we use prov.set_nic_settings to configure a nic with ip.

we need this information back when retiring: ips associated to nics.

vm.ipaddresses array returns all ip without nic information.

So how to do that?

ok i found informations:

ips and references to nic are in vm.hardware.networks association
vm.hardware.networks.each do |network|


nics are in vm.hardware.networks.nics:
vm.hardware.nics.each do |nic|


and network.device_id is

thanks to object_walker…


In older versions, the IP address information went away fairly soon after the VM was powered off (likely related to VMware tools). We specifically had that problem with retirement because we had some large delays built in between powering off and the rest of the state machine.

I haven’t checked recent versions to see if this is still a problem.

i have just verified: it is still the case today…networks structure is empty.

is there a way to store these informations elsewhere?

At provision time we record the IP in custom attributes so we can unregister it from DNS later.

This solution suffers a little bit because it does not synchronize if the IP of the VM is changed outside the process that also updates the attribute.