[libvirt-users] ruby-libvirt equiv of virsh list --all

Hi all, I have a working KVM system managed with virsh and virt-install. I am currently playing with ruby-libvirt-0.1.0. I am wanting to build a simple sinatra/ruby app to show the VE's on a node and their state. I have ruby 1.8.5 on CentOS 5.4. I have the basics of it worked out but am a little stuck. Is there a way of retrieving a list of all VM's on a host using ruby-libvirt. ie: virsh list --all ? @conn.list_defined_domains only shows VE's not started (lists VE names) @conn.list_domains only shows VE's running (lists VE id's) What I ultimately would like is to retrieve a full list of the uuid's of all defined VE's(running or not). -- Regards Mick Pollard ( lunix ) ------------------------------------------------ BOFH Excuse of the day: Extraneous Configuration Invalidation

On 04/27/2010 03:36 AM, Mick Pollard wrote:
Hi all,
I have a working KVM system managed with virsh and virt-install. I am currently playing with ruby-libvirt-0.1.0. I am wanting to build a simple sinatra/ruby app to show the VE's on a node and their state. I have ruby 1.8.5 on CentOS 5.4.
I have the basics of it worked out but am a little stuck. Is there a way of retrieving a list of all VM's on a host using ruby-libvirt. ie: virsh list --all ?
@conn.list_defined_domains only shows VE's not started (lists VE names) @conn.list_domains only shows VE's running (lists VE id's)
What I ultimately would like is to retrieve a full list of the uuid's of all defined VE's(running or not).
The ruby-libvirt library is just a thin wrapper around the libvirt API's. In point of fact, if you look at the libvirt API's (and virsh), you'll see that all virsh does is to take the two lists it gets back from list_defined_domains and list_domains, and concatenate them. So in ruby, you would do something similar to get the whole list, and then you'd have to iterate through each of them, dump the XML, and get the UUID out of it. -- Chris Lalancette

On Tue, 27 Apr 2010 10:02:15 -0400 Hi, Chris Lalancette <clalance@redhat.com> wrote:
The ruby-libvirt library is just a thin wrapper around the libvirt API's. In point of fact, if you look at the libvirt API's (and virsh), you'll see that all virsh does is to take the two lists it gets back from list_defined_domains and list_domains, and concatenate them. So in ruby, you would do something similar to get the whole list, and then you'd have to iterate through each of them, dump the XML, and get the UUID out of it.
-- Chris Lalancette
That's what I thought. Was just hoping for something a little more ellegant. Having to grab a list of stopped "names" and then running "id's" and convert to "uuid" just to grab a list of all the domains seems a little painful to me. Was hoping to for something like this: @conn.list_domains_uuid and have it grab all uuid's for domains running or not. Thanks -- Regards Mick Pollard ( lunix ) ------------------------------------------------ BOFH Excuse of the day: Static Hardware Condition Warning
participants (2)
-
Chris Lalancette
-
Mick Pollard