[Libvirt-cim] [PATCH] [CU] Add --print-ind switch to indication_tester

Jay Gagnon grendel at linux.vnet.ibm.com
Tue Jan 29 19:00:32 UTC 2008


# HG changeset patch
# User Jay Gagnon <grendel at linux.vnet.ibm.com>
# Date 1201633132 18000
# Node ID e8fc7748867b69799e119103684317b518315198
# Parent  2948ecbed2674aee61a994b06468c2ce9c763bb3
[CU] Add --print-ind switch to indication_tester

Sometimes just knowing you got the indication isn't informative enough, especially for early testing, so this patch adds an option to have the indication text printed out.  Adding the flag to the server feels a bit wrong, but it is *far* cleaner than extending the appropriate __init__ functions, so I'm okay with it.

Signed-off-by: Jay Gagnon <grendel at linux.vnet.ibm.com>

diff -r 2948ecbed267 -r e8fc7748867b tools/indication_tester.py
--- a/tools/indication_tester.py	Tue Jan 15 12:54:04 2008 +0100
+++ b/tools/indication_tester.py	Tue Jan 29 13:58:52 2008 -0500
@@ -292,14 +292,17 @@ class CIMSocketHandler(BaseHTTPServer.Ba
 
         indication = CIMIndication(data)
         print "Got indication: %s" % indication
+        if self.server.print_ind:
+            print "%s\n\n" % data
 
 class CIMIndicationSubscription:
-    def __init__(self, name, typ, ns):
+    def __init__(self, name, typ, ns, print_ind):
         self.name = name
         self.type = typ
         self.ns = ns
 
         self.server = BaseHTTPServer.HTTPServer(('', 8000), CIMSocketHandler)
+        self.server.print_ind = print_ind
         self.port = 8000
 
         self.filter_xml = filter_xml(name, typ, ns)
@@ -353,6 +356,9 @@ def main():
     parser.add_option("-d", "--dump-xml", dest="dump", default=False,
                       action="store_true",
                       help="Dump the xml that would be used and quit.")
+    parser.add_option("-p", "--print-ind", dest="print_ind", default=False,
+                      action="store_true",
+                      help="Print received indications to stdout.")
 
     (options, args) = parser.parse_args()
 
@@ -364,7 +370,8 @@ def main():
         dump_xml(options.name, args[0], options.ns)
         sys.exit(0)
     
-    sub = CIMIndicationSubscription(options.name, args[0], options.ns)
+    sub = CIMIndicationSubscription(options.name, args[0], options.ns,
+                                    options.print_ind)
     sub.subscribe(options.url)
     print "Watching for %s" % args[0]
 




More information about the Libvirt-cim mailing list