Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Obtaining the IP address of an vm #2

Closed
mdehollander opened this issue Jun 17, 2011 · 4 comments
Closed

Obtaining the IP address of an vm #2

mdehollander opened this issue Jun 17, 2011 · 4 comments

Comments

@mdehollander
Copy link

Hello,

How can I get the IP address of a virtual machine?

It is not listed as one of the attributes:
list(vmpool)[-1].xml.getchildren()

Out[15]: 
[<Element ID at 305d248>,
 <Element UID at 305d2d8>,
 <Element USERNAME at 305d368>,
 <Element NAME at 305d3f8>,
 <Element LAST_POLL at 305d488>,
 <Element STATE at 305d518>,
 <Element LCM_STATE at 305d5a8>,
 <Element STIME at 305d638>,
 <Element ETIME at 305d6c8>,
 <Element DEPLOY_ID at 305d758>,
 <Element MEMORY at 305d7e8>,
 <Element CPU at 305d878>,
 <Element NET_TX at 305d908>,
 <Element NET_RX at 305d998>,
 <Element LAST_SEQ at 305da28>,
 <Element HISTORY at 305dab8>]```

But I noticed that is provided as output of the one.vm.info function:
<IP><![CDATA[10.0.72.12]]></IP>

But all the fields that contain a CDATA value are note listed in the vmpool object.

Any ideas how to get the ip address into the vm object?

Thanks!
@lukaszo
Copy link
Owner

lukaszo commented Jun 18, 2011

Hi MaTiZ,

In opennebula version 2.0 and higher information about network is stored in template. For example to get all VM ips You can run:

[i.ip for i in list(vmpool)[0].template.nics]

but as already you know in Opennebula 1.4 there is no 'Template' element so I don't know how to get IP.

Can you send me output of:

from xml.etree import ElementTree
ElementTree.tostring(list(vmpool)[-1].xml)

@mdehollander
Copy link
Author

Hello Lukaszo,

The output of 'list(vmpool)[-1].xml' is:

<VM><ID>4635</ID><UID>75</UID><USERNAME>xxxxxx</USERNAME><NAME>Cloudman_Node</NAME><LAST_POLL>1308325540</LAST_POLL><STATE>3</STATE><LCM_STATE>3</LCM_STATE><STIME>1308322191</STIME><ETIME>0</ETIME><DEPLOY_ID>one-4635</DEPLOY_ID><MEMORY>1048576</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><HISTORY><SEQ>0</SEQ><HOSTNAME>node15-one</HOSTNAME><HID>51</HID><STIME>1308322217</STIME><ETIME>0</ETIME><PSTIME>1308322217</PSTIME><PETIME>1308322262</PETIME><RSTIME>1308322262</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM>

So no template or IP information there, but if I use the one.vm.info() function the template element is included:

Thanks!

@lukaszo
Copy link
Owner

lukaszo commented Jun 20, 2011

You may workaround this by running something like this:

for i in vmpool:
    i.info()

then you should be avle to get ip address:

[i.ip for i in list(vmpool)[0].template.nics]

But as you can see it's very inefficient. I don't see another way to do this in OpenNebula 1.4.

@lukaszo
Copy link
Owner

lukaszo commented Jul 5, 2011

If there is no more comments I'm closing this ticket.

@lukaszo lukaszo closed this as completed Jul 5, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants