How to find out all allocated IP's in OpenNebula

I can run the following to show me all the leased IP’s for each network:

$ onevnet show

but how do I find out ALL the leased IP’s for ALL the defined networks with a single command? I could call onvnet show through a loop over all the networks but that is slow and rather ugly. Looking for a single command, if possible.


You can use onevnet list --xml and process the output (XML format)

Thank you. However, this doesn’t show the leases.

[oneadmin@srv01 ~]$ onevnet list --xml | grep -Ei
[oneadmin@srv01 ~]$


[oneadmin@srv01 ~]$ onevnet show 26 --xml | grep -Ei
[oneadmin@srv01 ~]$


The IP adresses are in the AR_POOL/AR/ALLOCATED element of the returned XML. The format of this field is space separated list of INDEX ENCODED_VMID.

For example, if you have the following AR_POOL/AR:

      <ALLOCATED><![CDATA[ 1 68719477428 2 68719477429 3 68719477432 4 68719477433 5 68719477434 6 68719477435 7 68719477436 8 68719477438 9 68719477440]]></ALLOCATED>

There are 9 IPs allocated, with start IP
So you convert the first IP Address to IP Number and add the INDEX. Then convert back the result from IP Number to IP Address to have the dot notation.

For example, the last allocated IP is 167903528 + 9 = 167903537 where 167903537 is

Hope this helps.

Best Regards,
Anton Todorov

Thanks Anton. Got it.

What are numbers such as these?

68719477428 , 68719477429 , etc

If I’m just using the 1,2,3,4 etc.


These values are referenced as “binary_magic” in the OpenNebula code. The upper part of this 64bit value defines the type of the allocation, currently VM, VNet or VRouter. The lower value is the OID of the entry in case of VM, it is the VM’s ID. The value of 0xFFFFFFFF defines the allocation as on HOLD.

I’ve found the best summary in the network’s section of onedb fsck : one/network.rb at c26b6d470536b4c549c1968ac665716a78202eb4 · OpenNebula/one · GitHub

Hope this helps.

Best Regards,
Anton Todorov