Hi @Eviatar ,
I've run into the same questions when working with the Nutanix v4 API, and here’s what I’ve learned from my experience:
-
Primary IP Address Field: There isn’t a single, always-reliable field that guarantees the primary IP for a VM. However, in most of my use cases, I’ve found networkInfo.ipv4Info.learnedIpAddresses
to be the most consistent and accurate, especially when the VM has an active network connection and is communicating over the NIC. That said, I still check assignedIpAddresses
as a secondary reference when needed.
-
nicNetworkInfo vs networkInfo: This tripped me up at first too. From what I’ve seen, nicNetworkInfo
is more tied to individual virtual NICs, whereas networkInfo
gives a broader summary of the VM’s network interfaces. They can sometimes overlap in data, but they aren’t exact duplicates — nicNetworkInfo
tends to have more granular details.
Hope that helps! Curious to hear if others have found a more definitive source for the primary IP.
Hi @aluciani
Actually, there are quite a few different locations where IP addresses can be found for a single VM:
-
IpAddress
via vmm.v4.1.ahv.config.Ipv4Config
-
LearnedIpAddresses
via vmm.v4.1.ahv.config.Ipv4Info
-
Ipv4Config
via vmm.v4.1.ahv.config.VirtualEthernetNicNetworkInfo
→ NicNetworkInfo
-
Ipv4Info
via vmm.v4.1.ahv.config.VirtualEthernetNicNetworkInfo
→ NicNetworkInfo
-
Ipv6Info
via vmm.v4.1.ahv.config.VirtualEthernetNicNetworkInfo
→ NicNetworkInfo
-
Plus additional IPs coming from floating IP configurations, and potentially more.
This is becoming frustrating. Every time I want to retrieve all IPs associated with a VM (and make sure I haven’t missed any), I have to search across all these different fields.
I’m trying to find a way to consolidate or simplify this—ideally by using the $select
parameter. However, it seems too coarse-grained. For example, I can use $select=nics
, but not something more specific like:
- $select=common.v1.0.config.IPv4Address
- $select=common.v1.0.config.IPv6Address
or anything similar. Unfortunately, this doesn’t seem to work as expected.
Do you have any guidance or suggestions for a cleaner way to retrieve all IPs associated with a VM?
Thanks!