[libvirt] Get IP of ghost from remote with libvirt

angelo alfano angeloalfa at gmail.com
Fri Mar 5 12:40:33 UTC 2010


Hello everyone, sorry for my English,
I need to create a script (preferably in Python) that runs on a host
machine, I return the IP address of a Ghost running, providing its hostname.
In this VM is assigned the IP in DHCP with a network with this
configuration:

$ virsh net-dumpxml network1
Connecting to uri: qemu:///system
<network>
  <name>network1</name>
  <uuid>6050d8d4-4030-fdd5-ddfa-041c89bbdfa7</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' forwardDelay='0' />
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.2' end='192.168.100.254' />
    </dhcp>
  </ip>
</network>

While the configuration of one of the VM is:

$ virsh dumpxml test1
Connecting to uri: qemu:///system
<domain type='kvm' id='1'>
  <name>test1</name>
  <uuid>cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.11'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='cdrom'>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/var/lib/libvirt/images/test1.img'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='network'>
      <mac address='54:52:00:4e:59:0d'/>
      <source network='network1'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' keymap='it'/>
    <sound model='es1370'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
  </devices>
  <seclabel type='dynamic' model='apparmor'>
    <label>libvirt-cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</label>
    <imagelabel>libvirt-cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</imagelabel>
  </seclabel>
</domain>

Give me a hand?
Thanks

-- 
Angelo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100305/15c03f55/attachment-0001.htm>


More information about the libvir-list mailing list