[Ovirt-devel] [PATCH server] qpid/qmf python demo
Ian Main
imain at redhat.com
Fri Oct 10 21:56:49 UTC 2008
This is a little demo of the qpid interface in python.
This is just a temporary thing to demonstrate how it works.
Signed-off-by: Ian Main <imain at redhat.com>
---
src/qpid_list_demo.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100755 src/qpid_list_demo.py
diff --git a/src/qpid_list_demo.py b/src/qpid_list_demo.py
new file mode 100755
index 0000000..3b96c8a
--- /dev/null
+++ b/src/qpid_list_demo.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+# This script is temporary! It's just a demo to show how the qpid
+# stuff works. This prints out a hierarchy of nodes/domains/pools/volumes
+# every five seconds.
+
+from qpid.qmfconsole import Session
+import time
+
+s = Session()
+b = s.addBroker()
+
+while True:
+ nodes = s.getObjects(cls="node")
+ for node in nodes:
+ print 'node:', node.hostname
+ for prop in node.properties:
+ print " property:", prop
+ # Find any domains that on the current node.
+ domains = s.getObjects(cls="domain", node=node.objectId)
+ for domain in domains:
+ print ' domain:', domain.name
+ for prop in domain.properties:
+ print " property:", prop
+
+ pools = s.getObjects(cls="pool", node=node.objectId)
+ for pool in pools:
+ print ' pool:', pool.name
+ for prop in pool.properties:
+ print " property:", prop
+
+ # Find volumes that are part of the pool.
+ volumes = s.getObjects(cls="volume", pool=pool.objectId)
+ for volume in volumes:
+ print ' volume:', volume.name
+ for prop in volume.properties:
+ print " property:", prop
+
+ time.sleep(5)
+
+ print '----------------------------'
+
--
1.5.5.1
More information about the ovirt-devel
mailing list