[Libvirt-cim] [PATCH] [TEST] Check that the DefineSystem() result can be passed to GetInstance()

Dan Smith danms at us.ibm.com
Mon Jul 28 15:24:29 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1217258665 25200
# Node ID d1fb0dfbebaa98fd1e7fbcca1ce29dfb1bf44568
# Parent  3c80ea156a3c45bc321f9c465ba7692c011ab2e0
[TEST] Check that the DefineSystem() result can be passed to GetInstance()

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r 3c80ea156a3c -r d1fb0dfbebaa suites/libvirt-cim/cimtest/VirtualSystemManagementService/12_define_result.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/12_define_result.py	Mon Jul 28 08:24:25 2008 -0700
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+#    Dan Smith <danms at us.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+#
+
+sup_types = ['Xen', 'XenFV', 'KVM']
+default_dom = "define_test"
+
+import sys
+import pywbem
+from CimTest.ReturnCodes import FAIL, PASS
+from CimTest.Globals import do_main
+from CimTest.Globals import logger
+from CimTest import Globals 
+from XenKvmLib import vsms
+from XenKvmLib.classes import get_typed_class
+
+def define_system(host, virt, name, vssd, rasds):
+    vsms_class = eval("vsms." + \
+                          get_typed_class(virt,
+                                          "VirtualSystemManagementService"))
+
+    service = vsms_class(host)
+
+    rc, results = service.DefineSystem(SystemSettings=vssd,
+                                       ResourceSettings=rasds,
+                                       ReferenceConfiguration=' ')
+
+    system = results["ResultingSystem"]
+
+    return rc, system
+
+def get_instance_by_ref(host, ref):
+    conn = pywbem.WBEMConnection('http://%s' % host,
+                                 (Globals.CIM_USER, Globals.CIM_PASS),
+                                 ref.namespace)
+    return conn.GetInstance(ref)
+
+def define_test_system(options):
+    vssd_class = vsms.get_vssd_class(options.virt)
+    vssd = vssd_class(name=default_dom, virt=options.virt)
+
+    mrasd_class = vsms.get_masd_class(options.virt)
+    mrasd = mrasd_class(32, default_dom)
+
+    rc, system = define_system(options.ip,
+                               options.virt,
+                               default_dom,
+                               vssd.mof(),
+                               [mrasd.mof()])
+                                   
+    return system
+
+ at do_main(sup_types)
+def main():
+    options = main.options
+
+    systemref = define_test_system(options)
+    logger.info("GetInstance(%s)" % systemref)
+
+    if systemref.namespace is None:
+        logger.error("Returned reference had no namespace!")
+        return FAIL
+
+    system = get_instance_by_ref(options.ip, systemref)
+    
+    if system["Name"] == default_dom:
+        logger.info("Validated resulting system instance")
+        return PASS
+    else:
+        logger.error("Result system was: %s instead of %s" % (system["Name"],
+                                                              default_dom))
+        return FAIL
+    
+if __name__ == "__main__":
+    sys.exit(main())




More information about the Libvirt-cim mailing list