Difference between revisions of "Libvirt-qpid"
From Libvirt Wiki
ChrisBoyle (talk | contribs) (De-spam) |
|||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Installation == | == Installation == | ||
libvirt-qpid is currently available in Fedora 10 repositories so you can install it using yum | libvirt-qpid is currently available in Fedora 10 repositories so you can install it using yum |
Latest revision as of 11:40, 25 November 2010
Installation
libvirt-qpid is currently available in Fedora 10 repositories so you can install it using yum
# yum -y install libvirt-qpid qpidd python-qpid # chkconfig libvirt-qpid on # chkconfig qpidd on # service libvirt-qpid start # service qpidd start
Testing that it is running
We can check that it is running using qpid-tool and the list command
# qpid-tool Management Tool for QPID qpid: list Management Object Types: ObjectType Active Deleted ============================================ com.redhat.libvirt:domain 6 0 com.redhat.libvirt:node 1 0 com.redhat.libvirt:pool 1 0
Simple client in python
Now that we have it running lets make a simple client to get information from it. To do this I use python. The following is a simple script that does some of the basics
#!/usr/bin/env python from qmf.console import Session from yaml import dump sess = Session() # defaults to synchronous-only operation. It also defaults to user-management of connections. # attempt to connect to a broker try: broker = sess.addBroker('amqp://localhost:5672') print "Connection Success" except: print "Connection Failed" domains = sess.getObjects(_class='domain', _package='com.redhat.libvirt.domain') # Print a list of the domains for d in domains: print d # Select the first domain domain = domains[0] # Print a list of the properties of the domain print 'Properties:' props = domain.getProperties() for prop in props: print "\t",prop # Access a value of a property and print it print domain.name # Print a list of the methods of the domain print 'Methods:' meths = domain.getMethods() for meth in meths: print "\t",meth # Ca method of the domain and print it xmldesc = domain.getXMLDesc() # Call another method of the domain and print the result if domain.state == 'running': result = domain.shutdown() print result else: result = domain.create() print result # Disconnect from the broker (otherwise we hang the terminal sess.delBroker(broker)
Relevant Links
https://cwiki.apache.org/qpid/qmf-python-console-tutorial.html