[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] libvirt-python API for "domdisplay"

On 17.06.2013 17:19, mzawdx wrote:
> Hi all:
>     Work with virsh CLI, I can easy use the CLI " virsh -c
> qemu+tcp:// domdisplay instance-00000001" successfully:
> [root webmintest ~]#  virsh -c qemu+tcp:// domdisplay
> instance-00000001
> Please enter your authentication name: fred
> Please enter your password:
> vnc://
> However, I can find any libvit-python API related to this CLI, does it
> exist ?

No. The domdisplay command is pure virsh with a XPATH magic. The
algorithm is as follows:

1) dump the XML of desired domain
2) for i in "vnc", "spice", "rdp"; do
2a)   xpath = string(/domain/devices/graphics[ type='%s']/@port), %i
2b)   port = xpath_query($domxml, $xpath)
2c)   if !port continue
2d)   xpath = string(/domain/devices/graphics[ type='%s']/@listen), %i
2e)   listen = xpath_query($domxml, $xpath)
2f)   if ($i == "vnc) port -= 5900;
3) print %s://%s:%d, %i %listen %port

The whole source is here:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]