[PATCH 0 of 2] Add tc for the ReferencedConfiguration param of VSMS.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216686405 25200 # Node ID e14f791f1cb4f84ed3cad03c9099d336e232fb48 # Parent abcd4c8a873656b6f12c4416832d185f8c9eb151 [TEST] Fixes to support the ReferencedConfiguration VSMS param. These changes are needed to create a test case that tests the ReferencedConfiguration VSMS parameter. Fixes: -Add ref_config param to create_using_definesystem() - allows the caller to specify a reference for the ReferenceConfiguration param -Add enumerate_names() - Calls EnumerateInstanceNames() so the caller can get a list of CS references -Fix default_vssd_rasd_str() so that is a mac address is supplied to the function, it is used instead of one of the const.<> values. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Jul 21 10:33:31 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Jul 21 17:26:45 2008 -0700 @@ -64,8 +64,8 @@ return (0, cs) -def create_using_definesystem(domain_name, ip, - params=None, exp_err=None, virt='Xen'): +def create_using_definesystem(domain_name, ip, params=None, ref_config=' ', + exp_err=None, virt='Xen'): bug = "85673" try: class_vsms = eval('vsms.' + \ @@ -89,7 +89,7 @@ service.DefineSystem(SystemSettings=vssd, ResourceSettings=rasd, - ReferenceConfiguration=' ') + ReferenceConfiguration=ref_config) except pywbem.CIMError, (rc, desc): if rc == exp_rc and desc.find(exp_desc) >= 0: logger.info('Got expected rc code and error string.') diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt-cim/lib/XenKvmLib/computersystem.py --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Mon Jul 21 10:33:31 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Mon Jul 21 17:26:45 2008 -0700 @@ -95,6 +95,20 @@ return list +def enumerate_names(server, virt='Xen'): + conn = pywbem.WBEMConnection('http://%s' % server, + (Globals.CIM_USER, Globals.CIM_PASS), + Globals.CIM_NS) + classname = get_typed_class(virt, 'ComputerSystem') + + try: + refs = conn.EnumerateInstanceNames(classname) + except pywbem.CIMError, arg: + raise Exception(arg[1]) + return [] + + return refs + def system_of(server, iname): t = eval(iname["CreationClassName"]) diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 21 10:33:31 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 21 17:26:45 2008 -0700 @@ -263,7 +263,9 @@ return vssd.mof(), [d.mof(), m.mof()] class_nasd = get_nasd_class(virt) - if virt == 'KVM': + if net_mac != const.Xen_default_mac: + pass + elif virt == 'KVM': net_mac= const.KVM_default_mac elif virt == 'XenFV': net_mac = const.XenFV_default_mac

libvirt-cim-bounces@redhat.com wrote on 2008-07-22 08:34:00:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216686405 25200 # Node ID e14f791f1cb4f84ed3cad03c9099d336e232fb48 # Parent abcd4c8a873656b6f12c4416832d185f8c9eb151 [TEST] Fixes to support the ReferencedConfiguration VSMS param.
These changes are needed to create a test case that tests the ReferencedConfiguration VSMS parameter.
Fixes: -Add ref_config param to create_using_definesystem() - allows the caller to specify a reference for the ReferenceConfiguration param -Add enumerate_names() - Calls EnumerateInstanceNames() so the caller can get a list of CS references -Fix default_vssd_rasd_str() so that is a mac address is supplied to the function, it is used instead of one of the const.<> values.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt- cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Jul 21 10:33:31 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Jul 21 17:26:45 2008 -0700 @@ -64,8 +64,8 @@
return (0, cs)
-def create_using_definesystem(domain_name, ip, - params=None, exp_err=None, virt='Xen'): +def create_using_definesystem(domain_name, ip, params=None, ref_config=' ', + exp_err=None, virt='Xen'): bug = "85673" try: class_vsms = eval('vsms.' + \ @@ -89,7 +89,7 @@
service.DefineSystem(SystemSettings=vssd, ResourceSettings=rasd, - ReferenceConfiguration=' ') + ReferenceConfiguration=ref_config) except pywbem.CIMError, (rc, desc): if rc == exp_rc and desc.find(exp_desc) >= 0: logger.info('Got expected rc code and error string.') diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt- cim/lib/XenKvmLib/computersystem.py --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Mon Jul 21 10:33:31 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Mon Jul 21 17:26:45 2008 -0700 @@ -95,6 +95,20 @@
return list
+def enumerate_names(server, virt='Xen'): + conn = pywbem.WBEMConnection('http://%s' % server, + (Globals.CIM_USER, Globals.CIM_PASS), + Globals.CIM_NS) + classname = get_typed_class(virt, 'ComputerSystem') + + try: + refs = conn.EnumerateInstanceNames(classname) + except pywbem.CIMError, arg: + raise Exception(arg[1]) + return [] + + return refs + def system_of(server, iname): t = eval(iname["CreationClassName"])
diff -r abcd4c8a8736 -r e14f791f1cb4 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 21 10:33:312008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 21 17:26:452008 -0700 @@ -263,7 +263,9 @@ return vssd.mof(), [d.mof(), m.mof()]
class_nasd = get_nasd_class(virt) - if virt == 'KVM': + if net_mac != const.Xen_default_mac: + pass + elif virt == 'KVM': net_mac= const.KVM_default_mac elif virt == 'XenFV': net_mac = const.XenFV_default_mac
LXC network devices take a mac address argument as well?
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216686405 25200 # Node ID c2c0ac1f88c47405a0326dc7d019bbf931870dec # Parent e14f791f1cb4f84ed3cad03c9099d336e232fb48 [TEST] Add VSMS 10_referenced_config.py. This test creates a guest using default RASDS. Then another guest is defined using a reference of the first guest an the value for the ReferencedConfiguration parameter. This second guest is created with an additional network interface. The test verifies that the second guest is defined properly. It also verifies that the second guest has 2 network interfaces: one with a mac address that matches that of the first guest and one with a different mac address. This test current fails on LXC because the test suite doesn't pass a console device to the DefineSystem(). Will fix this in a follow up patch. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r e14f791f1cb4 -r c2c0ac1f88c4 suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py Mon Jul 21 17:26:45 2008 -0700 @@ -0,0 +1,169 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Kaitlin Rupert <karupert@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 +# + +import sys +import pywbem +from XenKvmLib.common_util import create_using_definesystem, \ + call_request_state_change, \ + poll_for_state_change +from XenKvmLib import vsms +from VirtLib import utils +from CimTest.Globals import logger, do_main +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.classes import get_typed_class +from XenKvmLib import computersystem + +sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +test_dom = 'rstest_domain' +test_dom2 = 'rstest_domain2' + +mac = "aa:aa:aa:00:00:00" + +REQUESTED_STATE = 2 +TIME = "00000000000000.000000:000" + +def setup_first_guest(ip, virt): + status = create_using_definesystem(test_dom, ip, virt=virt) + if status != PASS: + logger.error("Unable to define %s using DefineSystem()" % test_dom) + return FAIL + + rc = call_request_state_change(test_dom, ip, REQUESTED_STATE, TIME, virt) + if rc != 0: + logger.error("Unable to start %s" % test_dom) + return FAIL + + status = poll_for_state_change(ip, virt, test_dom, REQUESTED_STATE) + if status != PASS: + logger.error("%s didn't change state as expected" % test_dom) + return FAIL + + return PASS + +def get_ref(ip, virt): + cs_ref = None + + cs = computersystem.enumerate_names(ip, virt) + if len(cs) < 1: + logger.error("ComputerSystem EnumerateNames() returned no instances") + return cs_ref + + for ref in cs: + for item in ref.items(): + prop, val = item + if prop == "Name" and val == test_dom: + cs_ref = ref + + return cs_ref + +def get_vssd_rasd(virt): + vssd, def_rasd = vsms.default_vssd_rasd_str(dom_name=test_dom2, + net_type='network', + net_mac=mac, virt=virt) + + rasd = [] + for inst in def_rasd: + cn = get_typed_class(virt, "NetResourceAllocationSettingData") + if cn in inst: + rasd.append(inst) + + params = {} + + if len(rasd) != 1: + return params + + params['vssd'] = vssd + params['rasd'] = rasd + + return params + +def get_dom_macs(server, dom, virt): + mac_list = [] + + cmd = "virsh -c %s dumpxml %s | grep mac" % (utils.virt2uri(virt), dom) + ret, out = utils.run_remote(server, cmd) + if ret != 0: + return mac_list + + lines = out.splitlines() + for l in lines: + mac = l.split('=')[1] + mac = mac.lstrip('\'') + mac = mac.rstrip('\'/>') + mac_list.append(mac) + + return mac_list + +@do_main(sup_types) +def main(): + options = main.options + + try: + status = setup_first_guest(options.ip, options.virt) + if status != PASS: + raise Exception("Unable to start %s" % test_dom) + + ref = get_ref(options.ip, options.virt) + if ref is None: + raise Exception("Unable to get %s reference" % test_dom) + + define_params = get_vssd_rasd(options.virt) + if len(define_params) != 2: + raise Exception("Unable to build VSSD and RASD instances for %s" % \ + test_dom2) + + status = create_using_definesystem(test_dom2, options.ip, + params=define_params, ref_config=ref, + virt=options.virt) + if status != PASS: + raise Exception("Unable to define %s" % test_dom2) + + dom1_mac_list = get_dom_macs(options.ip, test_dom, options.virt) + if len(dom1_mac_list) != 1: + raise Exception("%s has %d macs, expected 1" % (test_dom, + len(dom1_mac_list))) + + dom2_mac_list = get_dom_macs(options.ip, test_dom2, options.virt) + if len(dom2_mac_list) != 2: + raise Exception("%s has %d macs, expected 1" % (test_dom2, + len(dom2_mac_list))) + + for item in dom2_mac_list: + if item != mac and item != dom1_mac_list[0]: + raise Exception("%s has unexpected mac value, exp: %s %s" % \ + (item, mac, dom1_mac_list[0])) + + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + destroy_and_undefine_domain(test_dom, options.ip, options.virt) + destroy_and_undefine_domain(test_dom2, options.ip, options.virt) + + return status + +if __name__ == "__main__": + sys.exit(main()) +

+1 from me =) Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 Kaitlin Rupert <kaitlin@linux.vnet.ibm.com> Sent by: libvirt-cim-bounces@redhat.com 2008-07-22 08:34 Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com> To libvirt-cim@redhat.com cc Subject [Libvirt-cim] [PATCH 2 of 2] [TEST] Add VSMS 10_referenced_config.py # HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216686405 25200 # Node ID c2c0ac1f88c47405a0326dc7d019bbf931870dec # Parent e14f791f1cb4f84ed3cad03c9099d336e232fb48 [TEST] Add VSMS 10_referenced_config.py. This test creates a guest using default RASDS. Then another guest is defined using a reference of the first guest an the value for the ReferencedConfiguration parameter. This second guest is created with an additional network interface. The test verifies that the second guest is defined properly. It also verifies that the second guest has 2 network interfaces: one with a mac address that matches that of the first guest and one with a different mac address. This test current fails on LXC because the test suite doesn't pass a console device to the DefineSystem(). Will fix this in a follow up patch. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r e14f791f1cb4 -r c2c0ac1f88c4 suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/10_referenced_config.py Mon Jul 21 17:26:45 2008 -0700 @@ -0,0 +1,169 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Kaitlin Rupert <karupert@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 +# + +import sys +import pywbem +from XenKvmLib.common_util import create_using_definesystem, \ + call_request_state_change, \ + poll_for_state_change +from XenKvmLib import vsms +from VirtLib import utils +from CimTest.Globals import logger, do_main +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.classes import get_typed_class +from XenKvmLib import computersystem + +sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +test_dom = 'rstest_domain' +test_dom2 = 'rstest_domain2' + +mac = "aa:aa:aa:00:00:00" + +REQUESTED_STATE = 2 +TIME = "00000000000000.000000:000" + +def setup_first_guest(ip, virt): + status = create_using_definesystem(test_dom, ip, virt=virt) + if status != PASS: + logger.error("Unable to define %s using DefineSystem()" % test_dom) + return FAIL + + rc = call_request_state_change(test_dom, ip, REQUESTED_STATE, TIME, virt) + if rc != 0: + logger.error("Unable to start %s" % test_dom) + return FAIL + + status = poll_for_state_change(ip, virt, test_dom, REQUESTED_STATE) + if status != PASS: + logger.error("%s didn't change state as expected" % test_dom) + return FAIL + + return PASS + +def get_ref(ip, virt): + cs_ref = None + + cs = computersystem.enumerate_names(ip, virt) + if len(cs) < 1: + logger.error("ComputerSystem EnumerateNames() returned no instances") + return cs_ref + + for ref in cs: + for item in ref.items(): + prop, val = item + if prop == "Name" and val == test_dom: + cs_ref = ref + + return cs_ref + +def get_vssd_rasd(virt): + vssd, def_rasd = vsms.default_vssd_rasd_str(dom_name=test_dom2, + net_type='network', + net_mac=mac, virt=virt) + + rasd = [] + for inst in def_rasd: + cn = get_typed_class(virt, "NetResourceAllocationSettingData") + if cn in inst: + rasd.append(inst) + + params = {} + + if len(rasd) != 1: + return params + + params['vssd'] = vssd + params['rasd'] = rasd + + return params + +def get_dom_macs(server, dom, virt): + mac_list = [] + + cmd = "virsh -c %s dumpxml %s | grep mac" % (utils.virt2uri(virt), dom) + ret, out = utils.run_remote(server, cmd) + if ret != 0: + return mac_list + + lines = out.splitlines() + for l in lines: + mac = l.split('=')[1] + mac = mac.lstrip('\'') + mac = mac.rstrip('\'/>') + mac_list.append(mac) + + return mac_list + +@do_main(sup_types) +def main(): + options = main.options + + try: + status = setup_first_guest(options.ip, options.virt) + if status != PASS: + raise Exception("Unable to start %s" % test_dom) + + ref = get_ref(options.ip, options.virt) + if ref is None: + raise Exception("Unable to get %s reference" % test_dom) + + define_params = get_vssd_rasd(options.virt) + if len(define_params) != 2: + raise Exception("Unable to build VSSD and RASD instances for %s" % \ + test_dom2) + + status = create_using_definesystem(test_dom2, options.ip, + params=define_params, ref_config=ref, + virt=options.virt) + if status != PASS: + raise Exception("Unable to define %s" % test_dom2) + + dom1_mac_list = get_dom_macs(options.ip, test_dom, options.virt) + if len(dom1_mac_list) != 1: + raise Exception("%s has %d macs, expected 1" % (test_dom, + len(dom1_mac_list))) + + dom2_mac_list = get_dom_macs(options.ip, test_dom2, options.virt) + if len(dom2_mac_list) != 2: + raise Exception("%s has %d macs, expected 1" % (test_dom2, + len(dom2_mac_list))) + + for item in dom2_mac_list: + if item != mac and item != dom1_mac_list[0]: + raise Exception("%s has unexpected mac value, exp: %s %s" % \ + (item, mac, dom1_mac_list[0])) + + status = PASS + + except Exception, details: + logger.error(details) + status = FAIL + + destroy_and_undefine_domain(test_dom, options.ip, options.virt) + destroy_and_undefine_domain(test_dom2, options.ip, options.virt) + + return status + +if __name__ == "__main__": + sys.exit(main()) + _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert