[PATCH] [TEST] #2 Check that the DefineSystem() result can be passed to GetInstance()

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1217262054 25200 # Node ID a39dc855b73eb6f5a960bc377a093d3fa953f926 # Parent 3c80ea156a3c45bc321f9c465ba7692c011ab2e0 [TEST] #2 Check that the DefineSystem() result can be passed to GetInstance() Changes: - Check that ResultingSystem is a REF instead of an instance too Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 3c80ea156a3c -r a39dc855b73e 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 09:20:54 2008 -0700 @@ -0,0 +1,97 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Dan Smith <danms@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 + +@do_main(sup_types) +def main(): + options = main.options + + systemref = define_test_system(options) + + if not isinstance(systemref, pywbem.CIMInstanceName): + logger.error("ResultingSystem is not a Reference!") + return FAIL + + if systemref.namespace is None: + logger.error("Returned reference had no namespace!") + return FAIL + + logger.info("GetInstance(%s)" % systemref) + 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())

+ +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"]
What if the DefineSystem call throws an exception or if results is None?
+ + 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) +
+ +@do_main(sup_types) +def main(): + options = main.options + + systemref = define_test_system(options) + + if not isinstance(systemref, pywbem.CIMInstanceName): + logger.error("ResultingSystem is not a Reference!") + return FAIL + + if systemref.namespace is None: + logger.error("Returned reference had no namespace!") + return FAIL + + logger.info("GetInstance(%s)" % systemref) + 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
You'll need to undefine the guest before the test returns in each if condition. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert