[PATCH 0 of 2] Fix VSMS 06_addresource.py failure.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214178778 25200 # Node ID 43aa81b757fdaedd9e9dd7ca70f15104962815d7 # Parent db29471408dcc1a2ecc315c1fc21e538cc08e411 [TEST] Add AddResource functions to vsms_util. Just add disk and network for now. AddResource() doesn't support processor and memory. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r db29471408dc -r 43aa81b757fd suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 10:46:24 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 16:52:58 2008 -0700 @@ -24,7 +24,8 @@ from CimTest import Globals from CimTest.ReturnCodes import FAIL, PASS from CimTest.Globals import logger -from VirtLib.live import network_by_bridge, virsh_vcpuinfo +from VirtLib.live import network_by_bridge, virsh_vcpuinfo, \ + get_bridge_from_network_xml def print_mod_err_msg(func_str, details): logger.error('Error invoking ModifyRS: %s' % func_str) @@ -104,3 +105,63 @@ return PASS +def print_add_err_msg(func_str, details): + logger.error('Error invoking AddRS: %s' % func_str) + logger.error(details) + +def add_disk_res(server, service, cxml, vssd_ref, dasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(dasd)]) + cxml.dumpxml(server) + disk_dev = cxml.get_value_xpath( + '/domain/devices/disk/target/@dev[. = "%s"]' % attr['nddev']) + dpath = cxml.get_value_xpath( + '/domain/devices/disk/source/@file[. = "%s"]' % attr['src_path']) + if disk_dev != attr['nddev'] or dpath != attr['src_path']: + logger.error("Got %s, exp %s. Got %s, exp %s" % (disk_dev, + attr['nddev'], dpath, attr['src_path'])) + raise Exception('Error adding rs for disk_dev') + logger.info('good status for disk path') + except Exception, details: + print_add_err_msg("add_disk_res", details) + return FAIL + + return PASS + +def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(nasd)]) + cxml.dumpxml(server) + + mac = cxml.get_value_xpath( + '/domain/devices/interface/mac/@address[. = "%s"]' + % attr['nmac']) + + if virt == "KVM": + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@network[. = "%s"]' + % attr['net_name']) + + else: + # For Xen, network interfaces are converted to bridge interfaces. + br = get_bridge_from_network_xml(attr['net_name'], server, virt) + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % br) + if name != None: + name = attr['net_name'] + + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("Got %s, exp %s. Got %s, exp %s." % (mac, + attr['nmac'], name, attr['net_name'])) + raise Exception('Error adding rs for net mac') + + logger.info('good status for net_mac') + except Exception, details: + print_add_err_msg("add_net_res", details) + return FAIL + + return PASS +

+1 for me Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214178778 25200 # Node ID 43aa81b757fdaedd9e9dd7ca70f15104962815d7 # Parent db29471408dcc1a2ecc315c1fc21e538cc08e411 [TEST] Add AddResource functions to vsms_util.
Just add disk and network for now. AddResource() doesn't support processor and memory.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r db29471408dc -r 43aa81b757fd suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 10:46:24 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 16:52:58 2008 -0700 @@ -24,7 +24,8 @@ from CimTest import Globals from CimTest.ReturnCodes import FAIL, PASS from CimTest.Globals import logger -from VirtLib.live import network_by_bridge, virsh_vcpuinfo +from VirtLib.live import network_by_bridge, virsh_vcpuinfo, \ + get_bridge_from_network_xml
def print_mod_err_msg(func_str, details): logger.error('Error invoking ModifyRS: %s' % func_str) @@ -104,3 +105,63 @@
return PASS
+def print_add_err_msg(func_str, details): + logger.error('Error invoking AddRS: %s' % func_str) + logger.error(details) + +def add_disk_res(server, service, cxml, vssd_ref, dasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(dasd)]) + cxml.dumpxml(server) + disk_dev = cxml.get_value_xpath( + '/domain/devices/disk/target/@dev[. = "%s"]' % attr['nddev']) + dpath = cxml.get_value_xpath( + '/domain/devices/disk/source/@file[. = "%s"]' % attr['src_path']) + if disk_dev != attr['nddev'] or dpath != attr['src_path']: + logger.error("Got %s, exp %s. Got %s, exp %s" % (disk_dev, + attr['nddev'], dpath, attr['src_path'])) + raise Exception('Error adding rs for disk_dev') + logger.info('good status for disk path') + except Exception, details: + print_add_err_msg("add_disk_res", details) + return FAIL + + return PASS + +def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(nasd)]) + cxml.dumpxml(server) + + mac = cxml.get_value_xpath( + '/domain/devices/interface/mac/@address[. = "%s"]' + % attr['nmac']) + + if virt == "KVM": + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@network[. = "%s"]' + % attr['net_name']) + + else: + # For Xen, network interfaces are converted to bridge interfaces. + br = get_bridge_from_network_xml(attr['net_name'], server, virt) + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % br) + if name != None: + name = attr['net_name'] + + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("Got %s, exp %s. Got %s, exp %s." % (mac, + attr['nmac'], name, attr['net_name'])) + raise Exception('Error adding rs for net mac') + + logger.info('good status for net_mac') + except Exception, details: + print_add_err_msg("add_net_res", details) + return FAIL + + return PASS +
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+1 for me . Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1214178778 25200 # Node ID 43aa81b757fdaedd9e9dd7ca70f15104962815d7 # Parent db29471408dcc1a2ecc315c1fc21e538cc08e411 [TEST] Add AddResource functions to vsms_util.
Just add disk and network for now. AddResource() doesn't support processor and memory.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r db29471408dc -r 43aa81b757fd suites/libvirt-cim/lib/XenKvmLib/vsms_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 10:46:24 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Sun Jun 22 16:52:58 2008 -0700 @@ -24,7 +24,8 @@ from CimTest import Globals from CimTest.ReturnCodes import FAIL, PASS from CimTest.Globals import logger -from VirtLib.live import network_by_bridge, virsh_vcpuinfo +from VirtLib.live import network_by_bridge, virsh_vcpuinfo, \ + get_bridge_from_network_xml
def print_mod_err_msg(func_str, details): logger.error('Error invoking ModifyRS: %s' % func_str) @@ -104,3 +105,63 @@
return PASS
+def print_add_err_msg(func_str, details): + logger.error('Error invoking AddRS: %s' % func_str) + logger.error(details) + +def add_disk_res(server, service, cxml, vssd_ref, dasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(dasd)]) + cxml.dumpxml(server) + disk_dev = cxml.get_value_xpath( + '/domain/devices/disk/target/@dev[. = "%s"]' % attr['nddev']) + dpath = cxml.get_value_xpath( + '/domain/devices/disk/source/@file[. = "%s"]' % attr['src_path']) + if disk_dev != attr['nddev'] or dpath != attr['src_path']: + logger.error("Got %s, exp %s. Got %s, exp %s" % (disk_dev, + attr['nddev'], dpath, attr['src_path'])) + raise Exception('Error adding rs for disk_dev') + logger.info('good status for disk path') + except Exception, details: + print_add_err_msg("add_disk_res", details) + return FAIL + + return PASS + +def add_net_res(server, service, virt, cxml, vssd_ref, nasd, attr): + try: + service.AddResourceSettings(AffectedConfiguration=vssd_ref, + ResourceSettings=[str(nasd)]) + cxml.dumpxml(server) + + mac = cxml.get_value_xpath( + '/domain/devices/interface/mac/@address[. = "%s"]' + % attr['nmac']) + + if virt == "KVM": + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@network[. = "%s"]' + % attr['net_name']) + + else: + # For Xen, network interfaces are converted to bridge interfaces. + br = get_bridge_from_network_xml(attr['net_name'], server, virt) + name = cxml.get_value_xpath( + '/domain/devices/interface/source/@bridge[. = "%s"]' + % br) + if name != None: + name = attr['net_name'] + + if mac != attr['nmac'] or name != attr['net_name']: + logger.error("Got %s, exp %s. Got %s, exp %s." % (mac, + attr['nmac'], name, attr['net_name'])) + raise Exception('Error adding rs for net mac') + + logger.info('good status for net_mac') + except Exception, details: + print_add_err_msg("add_net_res", details) + return FAIL + + return PASS +
_______________________________________________ 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 1213147580 25200 # Node ID fa81bbea248ae6e54fcc67073b521499d415f620 # Parent 43aa81b757fdaedd9e9dd7ca70f15104962815d7 [TEST] Modify VSMS 06 to support both a defined and running guest. These changes also include: -Use vsms_util AddResource() calls. -Remove add proc call - AddResource() doesn't support processor and memory. -Add logic so the test doesn't add a disk ro a running KVM guest (KVM only supports attaching CD type devices, another test case is needed for this). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 43aa81b757fd -r fa81bbea248a suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Sun Jun 22 16:52:58 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/06_addresource.py Tue Jun 10 18:26:20 2008 -0700 @@ -31,11 +31,18 @@ from CimTest.Globals import logger from CimTest.Globals import do_main from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib import vsms_util +from XenKvmLib.common_util import create_netpool_conf, destroy_netpool sup_types = ['Xen', 'KVM'] default_dom = 'rstest_domain' -nnmac = '99:aa:bb:cc:ee:ff' -npvcpu = 2 +nmac = '99:aa:bb:cc:ee:ff' +ntype = 'network' + +def cleanup_env(ip, virt, cxml, net_name): + destroy_netpool(ip, virt, net_name) + cxml.destroy(ip) + cxml.undefine(ip) @do_main(sup_types) def main(): @@ -49,51 +56,67 @@ service = vsms.get_vsms_class(options.virt)(options.ip) cxml = vxml.get_class(options.virt)(default_dom) classname = get_typed_class(options.virt, 'VirtualSystemSettingData') + inst_id = '%s:%s' % (options.virt, default_dom) vssd_ref = CIMInstanceName(classname, keybindings = { - 'InstanceID' : '%s:%s' % (options.virt, default_dom), + 'InstanceID' : inst_id, 'CreationClassName' : classname}) dasd = vsms.get_dasd_class(options.virt)(dev=nddev, source=cxml.secondary_disk_path, name=default_dom) - nasd = vsms.get_nasd_class(options.virt)(type='ethernet', mac=nnmac, - name=default_dom) - pasd = vsms.get_pasd_class(options.virt)(vcpu=npvcpu, name=default_dom) + disk_attr = { 'nddev' : nddev, + 'src_path' : cxml.secondary_disk_path + } + + status, net_name = create_netpool_conf(options.ip, options.virt, + use_existing=False) + if status != PASS: + logger.error('Unable to create network pool') + return FAIL + + nasd = vsms.get_nasd_class(options.virt)(type=ntype, + mac=nmac, + name=default_dom, + virt_net=net_name) + + net_attr = { 'ntype' : ntype, + 'net_name' : net_name, + 'nmac' : nmac + } status = FAIL - try: - cxml.define(options.ip) - # Add disk resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(dasd)]) - cxml.dumpxml(options.ip) - disk_dev = cxml.get_value_xpath( - '/domain/devices/disk/target/@dev[. = "%s"]' % nddev) - if disk_dev != nddev: - raise Exception('Error adding rs for disk_dev') - logger.info('good status for disk_dev') - # Add net resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(nasd)]) - cxml.dumpxml(options.ip) - net_mac = cxml.get_value_xpath( - '/domain/devices/interface/mac/@address[. = "%s"]' % nnmac) - if net_mac.lower() != nnmac: - raise Exception('Error adding rs for net_mac') - logger.info('good status for net_mac') - # Add processor resource setting - service.AddResourceSettings(AffectedConfiguration=vssd_ref, - ResourceSettings=[str(pasd)]) - cxml.dumpxml(options.ip) - proc_vcpu = cxml.xml_get_vcpu() - if int(proc_vcpu) != int(npvcpu): - raise Exception('Error adding rs for proc_vcpu') - logger.info('good status for proc_vcpu') - status = PASS - except Exception, details: - logger.error('Error invoking AddRS') - logger.error(details) - cxml.undefine(options.ip) + if options.virt == "KVM": + test_cases = ["define"] + else: + test_cases = ["define", "start"] + + for case in test_cases: + #Each time through, define guest using a default XML + cxml.undefine(options.ip) + cxml = vxml.get_class(options.virt)(default_dom) + ret = cxml.define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + if case == "start": + ret = cxml.start(options.ip) + if not ret: + logger.error("Failed to start the dom: %s", default_dom) + cleanup_env(options.ip, options.virt, cxml, net_name) + return FAIL + + status = vsms_util.add_disk_res(options.ip, service, cxml, vssd_ref, + dasd, disk_attr) + if status != PASS: + break + + status = vsms_util.add_net_res(options.ip, service, options.virt, cxml, + vssd_ref, nasd, net_attr) + if status != PASS: + break + + cleanup_env(options.ip, options.virt, cxml, net_name) return status
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert