# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1215544338 25200
# Node ID be269371a819744e742c24a55d011610cf6d3485
# Parent ef4c4ae1217b6f8e0f284178e6674ce3c9322f15
[CU] indication_tester.py enhancements
Add support for a port option. If nothing is supplied, port 8000 is used. Otherwise, the
value supplied is added to 8000. This allows for multiple copies of the indication_tester
to run at once.
Update delete_inst_xml() to take an inst_name argument. The classname needs to be
CIM_IndicationHandlerCIMXML, not CIM_IndicationHandler. However, the instance is created
with the instance name "%s%s" % (self.name, "Handler")
This has been tested with both Pegasus and sfcb.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ef4c4ae1217b -r be269371a819 tools/indication_tester.py
--- a/tools/indication_tester.py Tue Jul 01 11:25:17 2008 -0700
+++ b/tools/indication_tester.py Tue Jul 08 12:12:18 2008 -0700
@@ -169,7 +169,7 @@
</CIM>
""" % (sysname, name, sysname, name)
-def delete_inst_xml(name, type, sysname):
+def delete_inst_xml(name, type, sysname, inst_name):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -192,7 +192,7 @@
<KEYVALUE>CIM_Indication%s</KEYVALUE>
</KEYBINDING>
<KEYBINDING NAME="Name">
- <KEYVALUE>%s%s</KEYVALUE>
+ <KEYVALUE>%s</KEYVALUE>
</KEYBINDING>
</INSTANCENAME>
</IPARAMVALUE>
@@ -200,7 +200,7 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>;
- """ % (type, sysname, type, name, type);
+ """ % (type, sysname, type, inst_name);
def delete_sub_xml(name, sysname):
return """
@@ -298,13 +298,15 @@
self.server.indications.append(indication)
class CIMIndicationSubscription:
- def __init__(self, name, typ, ns, print_ind, sysname):
+ def __init__(self, name, typ, ns, print_ind, sysname, port=0):
self.name = name
self.type = typ
self.ns = ns
self.sysname = sysname
- self.server = BaseHTTPServer.HTTPServer(('', 8000), CIMSocketHandler)
+ self.port = 8000 + port
+ self.server = BaseHTTPServer.HTTPServer(('', self.port),
+ CIMSocketHandler)
self.server.print_ind = print_ind
self.port = 8000
self.server.indications = []
@@ -355,10 +357,12 @@
xml = delete_sub_xml(self.name, self.sysname)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
- xml = delete_inst_xml(self.name, "Handler", self.sysname)
+ xml = delete_inst_xml(self.name, "HandlerCIMXML", self.sysname,
+ "%sHandler" % self.name)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
- xml = delete_inst_xml(self.name, "Filter", self.sysname)
+ xml = delete_inst_xml(self.name, "Filter", self.sysname,
+ "%sFilter" % self.name)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
@@ -366,8 +370,9 @@
filter_str = filter_xml(name, typ, ns, sysname)
handler_str = handler_xml(name, 8000, sysname)
subscript_str = subscription_xml(name, sysname)
- del_filter_str = delete_inst_xml(name, "Filter", sysname)
- del_handler_str = delete_inst_xml(name, "Handler", sysname)
+ del_filter_str = delete_inst_xml(name, "Filter", sysname,
"%sFilter" % name)
+ del_handler_str = delete_inst_xml(name, "HandlerCIMXML", sysname,
+ "%sHandler" % name)
del_subscript_str = delete_sub_xml(name, sysname)
print "CreateFilter:\n%s\n" % filter_str
@@ -398,6 +403,8 @@
help="HTTP Auth username")
parser.add_option("-P", "--pass", dest="password",
default=None,
help="HTTP Auth password")
+ parser.add_option("--port", dest="port", default=0, type=int,
+ help="Port increment value (server default: 8000)")
(options, args) = parser.parse_args()
@@ -420,7 +427,7 @@
sys.exit(0)
sub = CIMIndicationSubscription(options.name, args[0], options.ns,
- options.print_ind, sysname)
+ options.print_ind, sysname, options.port)
sub.subscribe(options.url, auth)
print "Watching for %s" % args[0]