#!/usr/bin/env python # # Simple script to test libver-python reporting # # Copyright 2005-2006 Red Hat, Inc. # Angus Thomas # # This software may be freely redistributed under the terms of the GNU # general public license. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. domain_states="No State", "Running", "Blocked", "Paused", "Shutdown", "Shutoff", "Crashed" import libvir virt=libvir.open("Xen"); print ("Attached to a hypervisor of type - %s" % (virt.getType())); print ("There are currently %s domains running" % (virt.numOfDomains())); id_list=virt.listDomainsID(); for dom_id in id_list: dom=virt.lookupByID(dom_id); print ("\nDomain ID %s is named %s" % (dom_id, dom.name())); dom_info=dom.info(); # print ("\tState is %s" % (dom_info[0])); print ("\tState is %s" % (domain_states[dom_info[0]])); print ("\tmaxMem is %s" % (dom_info[1])); print ("\tmemory is %s" % (dom_info[2])); print ("\tnrVirtCpu is %s" % (dom_info[3])); print ("\tcpuTime is %s" % (dom_info[4]));