Ian Main
2008-Oct-31 18:32 UTC
[Ovirt-devel] [PATCH server] Replace python qpid example with ruby example.
This change removes the python qpid demo and replaces it with a shiny new ruby demo! Signed-off-by: Ian Main <imain at redhat.com> --- src/qmf-libvirt-example.rb | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/qpid_list_demo.py | 42 ----------------------------- 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 src/qmf-libvirt-example.rb delete mode 100755 src/qpid_list_demo.py diff --git a/src/qmf-libvirt-example.rb b/src/qmf-libvirt-example.rb new file mode 100644 index 0000000..5bfe44d --- /dev/null +++ b/src/qmf-libvirt-example.rb @@ -0,0 +1,62 @@ +#!/usr/bin/ruby + +require "rubygems" +require "qpid" + +s = Qpid::Qmf::Session.new() +b = s.add_broker("amqp://localhost:5672") + +while true: + nodes = s.objects(:class => "node") + nodes.each do |node| + puts "node: #{node.hostname}" + for (key, val) in node.properties + puts " property: #{key}, #{val}" + end + + # Find any domains that on the current node. + domains = s.objects(:class => "domain", 'node' => node.object_id) + domains.each do |domain| + r = domain.getXMLDesc() + puts "getXMLDesc() status: #{r.status}" + puts "getXMLDesc() status: #{r.text}" + if r.status == 0 + puts "xml length: #{r.description.length}" + end + + puts " domain: #{domain.name}, state: #{domain.state}, id: #{domain.id}" + for (key, val) in domain.properties + puts " property: #{key}, #{val}" + end + end + + pools = s.objects(:class => "pool", 'node' => node.object_id) + pools.each do |pool| + puts " pool: #{pool.name}" + for (key, val) in pool.properties + puts " property: #{key}, #{val}" + end + + r = pool.getXMLDesc() + puts "getXMLDesc() status: #{r.status}" + puts "getXMLDesc() text: #{r.text}" + if r.status == 0 + puts "xml length: #{r.description.length}" + end + + # Find volumes that are part of the pool. + volumes = s.objects(:class => "volume", 'pool' => pool.object_id) + volumes.each do |volume| + puts " volume: #{volume.name}" + for (key, val) in volume.properties + puts " property: #{key}, #{val}" + end + end + end + + end + + puts '----------------------------' + sleep(5) + +end diff --git a/src/qpid_list_demo.py b/src/qpid_list_demo.py deleted file mode 100755 index 3b96c8a..0000000 --- a/src/qpid_list_demo.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/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.6.5
Ian Main
2008-Oct-31 18:53 UTC
[Ovirt-devel] Re: [PATCH server] Replace python qpid example with ruby example.
Pushed. On Fri, 31 Oct 2008 11:32:30 -0700 Ian Main <imain at redhat.com> wrote:> This change removes the python qpid demo and replaces it > with a shiny new ruby demo! > > Signed-off-by: Ian Main <imain at redhat.com> > --- > src/qmf-libvirt-example.rb | 62 ++++++++++++++++++++++++++++++++++++++++++++ > src/qpid_list_demo.py | 42 ----------------------------- > 2 files changed, 62 insertions(+), 42 deletions(-) > create mode 100644 src/qmf-libvirt-example.rb > delete mode 100755 src/qpid_list_demo.py > > diff --git a/src/qmf-libvirt-example.rb b/src/qmf-libvirt-example.rb > new file mode 100644 > index 0000000..5bfe44d > --- /dev/null > +++ b/src/qmf-libvirt-example.rb > @@ -0,0 +1,62 @@ > +#!/usr/bin/ruby > + > +require "rubygems" > +require "qpid" > + > +s = Qpid::Qmf::Session.new() > +b = s.add_broker("amqp://localhost:5672") > + > +while true: > + nodes = s.objects(:class => "node") > + nodes.each do |node| > + puts "node: #{node.hostname}" > + for (key, val) in node.properties > + puts " property: #{key}, #{val}" > + end > + > + # Find any domains that on the current node. > + domains = s.objects(:class => "domain", 'node' => node.object_id) > + domains.each do |domain| > + r = domain.getXMLDesc() > + puts "getXMLDesc() status: #{r.status}" > + puts "getXMLDesc() status: #{r.text}" > + if r.status == 0 > + puts "xml length: #{r.description.length}" > + end > + > + puts " domain: #{domain.name}, state: #{domain.state}, id: #{domain.id}" > + for (key, val) in domain.properties > + puts " property: #{key}, #{val}" > + end > + end > + > + pools = s.objects(:class => "pool", 'node' => node.object_id) > + pools.each do |pool| > + puts " pool: #{pool.name}" > + for (key, val) in pool.properties > + puts " property: #{key}, #{val}" > + end > + > + r = pool.getXMLDesc() > + puts "getXMLDesc() status: #{r.status}" > + puts "getXMLDesc() text: #{r.text}" > + if r.status == 0 > + puts "xml length: #{r.description.length}" > + end > + > + # Find volumes that are part of the pool. > + volumes = s.objects(:class => "volume", 'pool' => pool.object_id) > + volumes.each do |volume| > + puts " volume: #{volume.name}" > + for (key, val) in volume.properties > + puts " property: #{key}, #{val}" > + end > + end > + end > + > + end > + > + puts '----------------------------' > + sleep(5) > + > +end > diff --git a/src/qpid_list_demo.py b/src/qpid_list_demo.py > deleted file mode 100755 > index 3b96c8a..0000000 > --- a/src/qpid_list_demo.py > +++ /dev/null > @@ -1,42 +0,0 @@ > -#!/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.6.5 >