[PATCH 0 of 2] [TEST] VSMS: ModifyResourceSettings to change cdrom media

This series introduces a new test case which covers a requirement to change the media in the CDROM using libvirt-cim, done via a ModifyResourceSettings call. Also changes the default domain created by cimtest to include a cdrom device. Signed-off-by: Eduardo Lima (Etrunko) <eblima@br.ibm.com> suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 + 3 files changed, 237 insertions(+), 0 deletions(-)

suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) <eblima@br.ibm.com> # Date 1317409066 10800 # Node ID 85c624ef88f4e1487f95a5e50674a626a4ebf8f4 # Parent f4bcd9833525c6914f61e29e9d2d8adbac240682 [TEST] 32_modify_cdrom_media.py: new test for VirtualSystemManagementService This test case covers a requirement to change the media in the CDROM using libvirt-cim, which is done via a ModifyResourceSettings call. Signed-off-by: Eduardo Lima (Etrunko) <eblima@br.ibm.com> diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py new file mode 100755 --- /dev/null +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python + +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko) <eblima@br.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 +# + +# +# Create a domain with cdrom device without media connected. +# ModifyResourceSettings call to change the cdrom media +# + +import sys +import os +import pywbem + +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS +from XenKvmLib.const import do_main, _image_dir +from XenKvmLib.classes import get_typed_class +from XenKvmLib.vxml import get_class + +supported = ['KVM',] + +cim = None +sys_mgmt_service = None +domain = None + +class CIMDomain(object): + + def __init__(self, name, virt, server): + self.name = name + self.server = server + self.virt = virt + self._domain = get_class(virt)(name) + #__init__ + + def define(self): + return self._domain.cim_define(self.server) + # define + + def undefine(self): + return self._domain.undefine(self.server) + # undefine + + def destroy(self): + return self._domain.cim_destroy(self.server) + #destroy +# CIMDomain + + +def set_device_addr(inst, address): + return """ +instance of %s { + InstanceID="%s"; + ResourceType=%d; + PoolID="%s"; + AllocationUnits="%s"; + Address="%s"; + VirtualQuantityUnits="%s"; + VirtualDevice="%s"; + EmulatedType=%d; + BusType="%s"; + DriverName="%s"; + DriverType="%s"; +};""" % (get_typed_class(domain.virt, "DiskResourceAllocationSettingData"), + inst["InstanceID"], + inst["ResourceType"], + inst["PoolID"], + inst["AllocationUnits"], + address, + inst["VirtualQuantityUnits"], + inst["VirtualDevice"], + inst["EmulatedType"], + inst["BusType"], + inst["DriverName"], + inst["DriverType"],) +# set_device_addr() + + +def modify_media(cim, inst, addr): + logger.info("Setting media addr to '%s'", addr) + + val = set_device_addr(inst, addr) + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],}) + + if ret[0]: + logger.error("Modifying media: %s", ret) + return None + + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) + new_addr = inst["Address"] + + if new_addr != addr: + logger.error("New media '%s' does not match expected '%s'", new_addr, addr) + return None + + return inst +# modify_media() + + +@do_main(supported) +def main(): + options = main.options + server = options.ip + virt = options.virt + + server_url = "http://%s" % server + global cim + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) + + _class = get_typed_class(virt, "VirtualSystemManagementService") + global sys_mgmt_service + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] + + # Create new domain + global domain + domain = CIMDomain("cimtest_modify_cdrom", virt, server) + if not domain.define(): + logger.error("Error defining test domain") + return FAIL + + logger.info("Domain XML\n%s", domain._domain) + # ein KVM_ComputerSystem + _class = get_typed_class(virt, "ComputerSystem") + computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] + + logger.info("ComputerSystem Names\n%s", computer_system_names) + + if not computer_system_names: + logger.info("Host has no domains defined") + return SKIP + + # ain -ac KVM_SystemDevice -arc KVM_LogicalDisk <KVM_ComputerSytem Name> + a_class = get_typed_class(virt, "SystemDevice") + r_class = get_typed_class(virt, "LogicalDisk") + logical_disk_names = [] + + for inst_name in computer_system_names: + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) + logical_disk_names.extend(assoc_names) + + logger.info("LogicalDisk Names\n%s", logical_disk_names) + + if not logical_disk_names: + logger.info("No LogicalDisk instances returned") + return FAIL + + # ai -arc KVM_DiskResourceAllocationSettingData <KVM_LogicalDisk Name> + rclass = get_typed_class(virt, "DiskResourceAllocationSettingData") + disk_rasd_names = [] + + for inst_name in logical_disk_names: + assoc_names = cim.AssociatorNames(inst_name, ResultClass=rclass) + disk_rasd_names.extend(assoc_names) + + logger.info("DiskRASD names\n%s", disk_rasd_names) + + if not disk_rasd_names: + logger.info("No DiskRASD instances returned") + return FAIL + + cdrom_devices = [i for i in disk_rasd_names if cim.GetInstance(i)["EmulatedType"] == 1] + + logger.info("CDROM devices\n%s", cdrom_devices) + + if not cdrom_devices: + logger.info("No CDROM device found") + return FAIL + + cdrom = cdrom_devices[0] + inst = cim.GetInstance(cdrom) + + for media in ["cdrom01.iso", "cdrom02.iso"]: + if not inst: + logger.error("Unable to get CDROM device instance") + return FAIL + + # Get current media address + old_media = inst["Address"] + + logger.info("Current CDROM media: '%s'", old_media) + + if not media and not old_media: + logger.info("CDROM device has no media connected") + continue + + # Need to eject first? + if media and old_media: + inst = modify_media(cim, inst, "") + + media_path = os.path.join(_image_dir, media) + inst = modify_media(cim, inst, media_path) + + return PASS +# main() + +if __name__ == "__main__": + ret = main() + + if domain: + domain.destroy() + domain.undefine() + + sys.exit(ret)

tested, good case with nice skills.. But does this case included the situation that changing media when guest is running? 于 2011-10-1 2:59, Eduardo Lima (Etrunko) 写道:
suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-)
# HG changeset patch # User Eduardo Lima (Etrunko)<eblima@br.ibm.com> # Date 1317409066 10800 # Node ID 85c624ef88f4e1487f95a5e50674a626a4ebf8f4 # Parent f4bcd9833525c6914f61e29e9d2d8adbac240682 [TEST] 32_modify_cdrom_media.py: new test for VirtualSystemManagementService
This test case covers a requirement to change the media in the CDROM using libvirt-cim, which is done via a ModifyResourceSettings call.
Signed-off-by: Eduardo Lima (Etrunko)<eblima@br.ibm.com>
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py new file mode 100755 --- /dev/null +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python + +# +# Copyright 2011 IBM Corp. +# +# Authors: +# Eduardo Lima (Etrunko)<eblima@br.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 +# + +# +# Create a domain with cdrom device without media connected. +# ModifyResourceSettings call to change the cdrom media +# + +import sys +import os +import pywbem + +from CimTest.ReturnCodes import PASS, FAIL, XFAIL, SKIP +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS +from XenKvmLib.const import do_main, _image_dir +from XenKvmLib.classes import get_typed_class +from XenKvmLib.vxml import get_class + +supported = ['KVM',] + +cim = None +sys_mgmt_service = None +domain = None + +class CIMDomain(object): + + def __init__(self, name, virt, server): + self.name = name + self.server = server + self.virt = virt + self._domain = get_class(virt)(name) + #__init__ + + def define(self): + return self._domain.cim_define(self.server) + # define + + def undefine(self): + return self._domain.undefine(self.server) + # undefine + + def destroy(self): + return self._domain.cim_destroy(self.server) + #destroy +# CIMDomain + + +def set_device_addr(inst, address): + return """ +instance of %s { + InstanceID="%s"; + ResourceType=%d; + PoolID="%s"; + AllocationUnits="%s"; + Address="%s"; + VirtualQuantityUnits="%s"; + VirtualDevice="%s"; + EmulatedType=%d; + BusType="%s"; + DriverName="%s"; + DriverType="%s"; +};""" % (get_typed_class(domain.virt, "DiskResourceAllocationSettingData"), + inst["InstanceID"], + inst["ResourceType"], + inst["PoolID"], + inst["AllocationUnits"], + address, + inst["VirtualQuantityUnits"], + inst["VirtualDevice"], + inst["EmulatedType"], + inst["BusType"], + inst["DriverName"], + inst["DriverType"],) +# set_device_addr() + + +def modify_media(cim, inst, addr): + logger.info("Setting media addr to '%s'", addr) + + val = set_device_addr(inst, addr) + ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],}) + + if ret[0]: + logger.error("Modifying media: %s", ret) + return None + + inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0]) + new_addr = inst["Address"] + + if new_addr != addr: + logger.error("New media '%s' does not match expected '%s'", new_addr, addr) + return None + + return inst +# modify_media() + + +@do_main(supported) +def main(): + options = main.options + server = options.ip + virt = options.virt + + server_url = "http://%s" % server + global cim + cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS) + + _class = get_typed_class(virt, "VirtualSystemManagementService") + global sys_mgmt_service + sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0] + + # Create new domain + global domain + domain = CIMDomain("cimtest_modify_cdrom", virt, server) + if not domain.define(): + logger.error("Error defining test domain") + return FAIL + + logger.info("Domain XML\n%s", domain._domain) + # ein KVM_ComputerSystem + _class = get_typed_class(virt, "ComputerSystem") + computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name] + + logger.info("ComputerSystem Names\n%s", computer_system_names) + + if not computer_system_names: + logger.info("Host has no domains defined") + return SKIP + + # ain -ac KVM_SystemDevice -arc KVM_LogicalDisk<KVM_ComputerSytem Name> + a_class = get_typed_class(virt, "SystemDevice") + r_class = get_typed_class(virt, "LogicalDisk") + logical_disk_names = [] + + for inst_name in computer_system_names: + assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class) + logical_disk_names.extend(assoc_names) + + logger.info("LogicalDisk Names\n%s", logical_disk_names) + + if not logical_disk_names: + logger.info("No LogicalDisk instances returned") + return FAIL + + # ai -arc KVM_DiskResourceAllocationSettingData<KVM_LogicalDisk Name> + rclass = get_typed_class(virt, "DiskResourceAllocationSettingData") + disk_rasd_names = [] + + for inst_name in logical_disk_names: + assoc_names = cim.AssociatorNames(inst_name, ResultClass=rclass) + disk_rasd_names.extend(assoc_names) + + logger.info("DiskRASD names\n%s", disk_rasd_names) + + if not disk_rasd_names: + logger.info("No DiskRASD instances returned") + return FAIL + + cdrom_devices = [i for i in disk_rasd_names if cim.GetInstance(i)["EmulatedType"] == 1] + + logger.info("CDROM devices\n%s", cdrom_devices) + + if not cdrom_devices: + logger.info("No CDROM device found") + return FAIL + + cdrom = cdrom_devices[0] + inst = cim.GetInstance(cdrom) + + for media in ["cdrom01.iso", "cdrom02.iso"]: + if not inst: + logger.error("Unable to get CDROM device instance") + return FAIL + + # Get current media address + old_media = inst["Address"] + + logger.info("Current CDROM media: '%s'", old_media) + + if not media and not old_media: + logger.info("CDROM device has no media connected") + continue + + # Need to eject first? + if media and old_media: + inst = modify_media(cim, inst, "") + + media_path = os.path.join(_image_dir, media) + inst = modify_media(cim, inst, media_path) + + return PASS +# main() + +if __name__ == "__main__": + ret = main() + + if domain: + domain.destroy() + domain.undefine() + + sys.exit(ret)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Best Regards Wayne Xia mail:xiawenc@linux.vnet.ibm.com tel:86-010-82450803

suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) # HG changeset patch # User Eduardo Lima (Etrunko) <eblima@br.ibm.com> # Date 1317408948 10800 # Node ID f4bcd9833525c6914f61e29e9d2d8adbac240682 # Parent eac4909ac68adc28cad9cb6389ea93a053b23aec [TEST] XenKvmLib: Add cdrom device description to domain The default domain created by libvirt-cim did not include a cdrom device, which is required by a new test for VirtualSystemManagementService. Signed-off-by: Eduardo Lima (Etrunko) <eblima@br.ibm.com> diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -87,6 +87,7 @@ KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') KVM_default_disk_dev = 'hda' +KVM_default_cdrom_dev = 'hdc' KVM_default_mac = '11:22:33:aa:bb:cc' # vxml.XenFVXML diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py @@ -628,6 +628,12 @@ self.iasd = vsms.get_iasd_class(virt)(name=dom_name, res_sub_type=irstype, bus_type=btype) + if virt == "KVM": + dasd = vsms.get_dasd_class(virt) + self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, + source="", + name=dom_name, + emu_type=1) def cim_define(self, ip, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) sys_settings = str(self.vssd) @@ -645,6 +651,10 @@ else: res_settings.append(str(self.nasd)) + # CDROM device + if self.virt == "KVM": + res_settings.append(str(self.cdrom_dasd)) + curr_cim_rev, changeset = get_provider_version(self.virt, ip) if curr_cim_rev >= vsms_graphics_sup: if self.gasd is not None: @@ -941,6 +951,11 @@ disk = self.add_sub_node(devices, 'disk', type='file', device='disk') self.add_sub_node(disk, 'source', file=disk_img) self.add_sub_node(disk, 'target', dev=disk_dev) + + cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') + self.add_sub_node(cdrom, 'source', file="") + self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) + self.add_sub_node(devices, 'input', type='mouse', bus='ps2') self.add_sub_node(devices, 'graphics', type='vnc', port='5900', keymap='en-us')

# ll /var/lib/libvirt/images total 16844232 -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso After extracting the .iso files and applying both patches, I get the following error: Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match expected '' ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 209, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 100, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 83, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None -------------------------------------------------------------------- On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote:
suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
# HG changeset patch # User Eduardo Lima (Etrunko)<eblima@br.ibm.com> # Date 1317408948 10800 # Node ID f4bcd9833525c6914f61e29e9d2d8adbac240682 # Parent eac4909ac68adc28cad9cb6389ea93a053b23aec [TEST] XenKvmLib: Add cdrom device description to domain
The default domain created by libvirt-cim did not include a cdrom device, which is required by a new test for VirtualSystemManagementService.
Signed-off-by: Eduardo Lima (Etrunko)<eblima@br.ibm.com>
diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -87,6 +87,7 @@ KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') KVM_default_disk_dev = 'hda' +KVM_default_cdrom_dev = 'hdc' KVM_default_mac = '11:22:33:aa:bb:cc'
# vxml.XenFVXML diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py @@ -628,6 +628,12 @@ self.iasd = vsms.get_iasd_class(virt)(name=dom_name, res_sub_type=irstype, bus_type=btype) + if virt == "KVM": + dasd = vsms.get_dasd_class(virt) + self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, + source="", + name=dom_name, + emu_type=1) def cim_define(self, ip, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) sys_settings = str(self.vssd) @@ -645,6 +651,10 @@ else: res_settings.append(str(self.nasd))
+ # CDROM device + if self.virt == "KVM": + res_settings.append(str(self.cdrom_dasd)) + curr_cim_rev, changeset = get_provider_version(self.virt, ip) if curr_cim_rev>= vsms_graphics_sup: if self.gasd is not None: @@ -941,6 +951,11 @@ disk = self.add_sub_node(devices, 'disk', type='file', device='disk') self.add_sub_node(disk, 'source', file=disk_img) self.add_sub_node(disk, 'target', dev=disk_dev) + + cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') + self.add_sub_node(cdrom, 'source', file="") + self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) + self.add_sub_node(devices, 'input', type='mouse', bus='ps2') self.add_sub_node(devices, 'graphics', type='vnc', port='5900', keymap='en-us')
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

于 2011-10-13 20:37, Chip Vincent 写道:
# ll /var/lib/libvirt/images total 16844232 -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso
After extracting the .iso files and applying both patches, I get the following error:
Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match expected '' ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 209, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 100, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 83, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None --------------------------------------------------------------------
strange, I think the case failed in the switch phase: cdrom01.iso->empty->cdrom2.iso. ERROR - TypeError : 'NoneType' object is unsubscriptable seems related to a python grammar issue, maybe it is caused by python version, what is it on your PC? Mine version: python 2.6.6 Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) Kernel: 2.6.32-71.el6.x86_64 libvirt: 0.9.4 Hypervisor: QEMU 0.14.50 CIMOM: Pegasus 2.9.1 Libvirt-cim revision: 1152 Libvirt-cim changeset: 2714b9a5e842+ Cimtest revision: 881 Cimtest changeset: a550ae7da806
On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote:
suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
# HG changeset patch # User Eduardo Lima (Etrunko)<eblima@br.ibm.com> # Date 1317408948 10800 # Node ID f4bcd9833525c6914f61e29e9d2d8adbac240682 # Parent eac4909ac68adc28cad9cb6389ea93a053b23aec [TEST] XenKvmLib: Add cdrom device description to domain
The default domain created by libvirt-cim did not include a cdrom device, which is required by a new test for VirtualSystemManagementService.
Signed-off-by: Eduardo Lima (Etrunko)<eblima@br.ibm.com>
diff --git a/suites/libvirt-cim/lib/XenKvmLib/const.py b/suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py @@ -87,6 +87,7 @@ KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') KVM_default_disk_dev = 'hda' +KVM_default_cdrom_dev = 'hdc' KVM_default_mac = '11:22:33:aa:bb:cc'
# vxml.XenFVXML diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py @@ -628,6 +628,12 @@ self.iasd = vsms.get_iasd_class(virt)(name=dom_name, res_sub_type=irstype, bus_type=btype) + if virt == "KVM": + dasd = vsms.get_dasd_class(virt) + self.cdrom_dasd = dasd(dev=const.KVM_default_cdrom_dev, + source="", + name=dom_name, + emu_type=1) def cim_define(self, ip, ref_conf=None): service = vsms.get_vsms_class(self.virt)(ip) sys_settings = str(self.vssd) @@ -645,6 +651,10 @@ else: res_settings.append(str(self.nasd))
+ # CDROM device + if self.virt == "KVM": + res_settings.append(str(self.cdrom_dasd)) + curr_cim_rev, changeset = get_provider_version(self.virt, ip) if curr_cim_rev>= vsms_graphics_sup: if self.gasd is not None: @@ -941,6 +951,11 @@ disk = self.add_sub_node(devices, 'disk', type='file', device='disk') self.add_sub_node(disk, 'source', file=disk_img) self.add_sub_node(disk, 'target', dev=disk_dev) + + cdrom = self.add_sub_node(devices, 'disk', type='file', device='cdrom') + self.add_sub_node(cdrom, 'source', file="") + self.add_sub_node(cdrom, 'target', dev=const.KVM_default_cdrom_dev) + self.add_sub_node(devices, 'input', type='mouse', bus='ps2') self.add_sub_node(devices, 'graphics', type='vnc', port='5900', keymap='en-us')
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Best Regards Wayne Xia mail:xiawenc@linux.vnet.ibm.com tel:86-010-82450803

On 10/14/2011 03:50 AM, Wayne Xia wrote:
于 2011-10-13 20:37, Chip Vincent 写道: [snip] strange, I think the case failed in the switch phase: cdrom01.iso->empty->cdrom2.iso.
ERROR - TypeError : 'NoneType' object is unsubscriptable seems related to a python grammar issue, maybe it is caused by python version, what is it on your PC?
Mine version: python 2.6.6 Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) Kernel: 2.6.32-71.el6.x86_64 libvirt: 0.9.4 Hypervisor: QEMU 0.14.50 CIMOM: Pegasus 2.9.1 Libvirt-cim revision: 1152 Libvirt-cim changeset: 2714b9a5e842+ Cimtest revision: 881 Cimtest changeset: a550ae7da806
python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

Chip, Are you seeing the "NoneType" object error only when running this test case? Other tests on the machine are passing/running? Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM Chip Vincent <cvincent@linux.v net.ibm.com> To Sent by: libvirt-cim@redhat.com libvirt-cim-bounc cc es@redhat.com Subject Re: [Libvirt-cim] [PATCH 2 of 2] 10/14/2011 04:25 [TEST] XenKvmLib: Add cdrom device AM description to domain Please respond to cvincent@linux.vn et.ibm.com; Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redh at.com> On 10/14/2011 03:50 AM, Wayne Xia wrote:
于 2011-10-13 20:37, Chip Vincent 写道: [snip] strange, I think the case failed in the switch phase: cdrom01.iso->empty->cdrom2.iso.
ERROR - TypeError : 'NoneType' object is unsubscriptable seems related to a python grammar issue, maybe it is caused by python version, what is it on your PC?
Mine version: python 2.6.6 Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) Kernel: 2.6.32-71.el6.x86_64 libvirt: 0.9.4 Hypervisor: QEMU 0.14.50 CIMOM: Pegasus 2.9.1 Libvirt-cim revision: 1152 Libvirt-cim changeset: 2714b9a5e842+ Cimtest revision: 881 Cimtest changeset: a550ae7da806
python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

I did not see any errors once I upgraded to tog-pegasus-2.11.1. Chip Vincent Open Virtualization, Linux Technology Center IBM Systems & Technology Group phone: 919-254-4482, T/L 444-4482 email: cvincent@us.ibm.com From: Sharad Mishra/Beaverton/IBM@IBMUS To: <libvirt-cim@redhat.com> Date: 10/17/2011 01:57 PM Subject: Re: [Libvirt-cim] [PATCH 2 of 2] [TEST] XenKvmLib: Add cdrom device description to domain Sent by: libvirt-cim-bounces@redhat.com Chip, Are you seeing the "NoneType" object error only when running this test case? Other tests on the machine are passing/running? Regards, Sharad Mishra Open Virtualization Linux Technology Center IBM Inactive hide details for Chip Vincent ---10/14/2011 04:27:59 AM---On 10/14/2011 03:50 AM, Wayne Xia wrote:Chip Vincent ---10/14/2011 04:27:59 AM---On 10/14/2011 03:50 AM, Wayne Xia wrote: Chip Vincent <cvincen t@linux. vnet.ibm To .com> Sent by: libvirt-cim@redhat.com libvirt- cim-boun cc ces@redh at.com Subject 10/14/20 Re: [Libvirt-cim] [PATCH 2 of 2] 11 04:25 [TEST] XenKvmLib: Add cdrom AM device description to domain Please respond to cvincent@linux.vnet.ibm.com; Please respond to List for discussion and development of libvirt CIM <libvirt-cim@redhat.com> On 10/14/2011 03:50 AM, Wayne Xia wrote:
于 2011-10-13 20:37, Chip Vincent 写道: [snip] strange, I think the case failed in the switch phase: cdrom01.iso->empty->cdrom2.iso.
ERROR - TypeError : 'NoneType' object is unsubscriptable seems related to a python grammar issue, maybe it is caused by python version, what is it on your PC?
Mine version: python 2.6.6 Distro: Red Hat Enterprise Linux Server release 6.0 (Santiago) Kernel: 2.6.32-71.el6.x86_64 libvirt: 0.9.4 Hypervisor: QEMU 0.14.50 CIMOM: Pegasus 2.9.1 Libvirt-cim revision: 1152 Libvirt-cim changeset: 2714b9a5e842+ Cimtest revision: 881 Cimtest changeset: a550ae7da806
python-2.6.5-3 Red Hat Enterprise Linux Workstation release 6.0 (Santiago) Kernel: 2.6.32-71.29.1 libvirt: libvirt-0.8.7-18 qemu: qemu-kvm-0.12.1.2-2.113 pegasus: tog-pegasus-2.11.0-1 Libvirt-cim changeset: 2714b9a5e842 Cimtest changeset: 5934d6b1d016 (latest) plus both cdrom patches -- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim[attachment "pic06979.gif" deleted by Chip Vincent/Raleigh/IBM] _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

On 10/13/2011 09:37 AM, Chip Vincent wrote:
# ll /var/lib/libvirt/images total 16844232 -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso
After extracting the .iso files and applying both patches, I get the following error:
Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match expected ''
This may be related to the version of pegasus you have installed in your machine. This test case is very similar to the 31_unset_netrasd that I have posted. It will issue a ModifyResourceSettings call with an empty string to eject the media. See my previous email on the thread about the unset_netrasd patch.
ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 209, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 100, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 83, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None --------------------------------------------------------------------
Now about this error, I see an oportunity of an extra check for None in order to avoid this traceback. There are also a few small syntax fixes elsewhere that I will post later on today. Best regards, Etrunko -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima@br.ibm.com

+1. With tog-pegasus-2.11.1 I get the following: Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: PASS -------------------------------------------------------------------- NOTE: If you're not already on tog-pegasus-2.11.1, please move to it. On 10/14/2011 11:58 AM, Eduardo Lima (Etrunko) wrote:
On 10/13/2011 09:37 AM, Chip Vincent wrote:
# ll /var/lib/libvirt/images total 16844232 -rw------- 1 root root 372736 Sep 30 14:21 cdrom01.iso -rw------- 1 root root 372736 Sep 30 14:21 cdrom02.iso
After extracting the .iso files and applying both patches, I get the following error:
Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 32_modify_cdrom_media.py: FAIL ERROR - New media '/var/lib/libvirt/images/cdrom01.iso' does not match expected ''
This may be related to the version of pegasus you have installed in your machine. This test case is very similar to the 31_unset_netrasd that I have posted. It will issue a ModifyResourceSettings call with an empty string to eject the media. See my previous email on the thread about the unset_netrasd patch.
ERROR - TypeError : 'NoneType' object is unsubscriptable Traceback (most recent call last): File "/home/cvincent/proj/dev/tmp/cimtest/suites/libvirt-cim/lib/XenKvmLib/const.py", line 141, in do_try rc = f() File "32_modify_cdrom_media.py", line 209, in main inst = modify_media(cim, inst, media_path) File "32_modify_cdrom_media.py", line 100, in modify_media val = set_device_addr(inst, addr) File "32_modify_cdrom_media.py", line 83, in set_device_addr inst["InstanceID"], TypeError: 'NoneType' object is unsubscriptable ERROR - None --------------------------------------------------------------------
Now about this error, I see an oportunity of an extra check for None in order to avoid this traceback. There are also a few small syntax fixes elsewhere that I will post later on today.
Best regards, Etrunko
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

The iso files used in this test can be found attached to this email and must be placed in /var/lib/libvirt/images. Best regards, -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima@br.ibm.com

Pushed. On 09/30/2011 02:59 PM, Eduardo Lima (Etrunko) wrote:
This series introduces a new test case which covers a requirement to change the media in the CDROM using libvirt-cim, done via a ModifyResourceSettings call.
Also changes the default domain created by cimtest to include a cdrom device.
Signed-off-by: Eduardo Lima (Etrunko)<eblima@br.ibm.com>
suites/libvirt-cim/cimtest/VirtualSystemManagementService/32_modify_cdrom_media.py | 221 ++++++++++ suites/libvirt-cim/lib/XenKvmLib/const.py | 1 + suites/libvirt-cim/lib/XenKvmLib/vxml.py | 15 + 3 files changed, 237 insertions(+), 0 deletions(-)
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com

On 10/14/2011 03:43 PM, Chip Vincent wrote:
Pushed.
I have just found that the patch that adds a cdrom device to the default domain causes some collateral effects on the whole suite. My bad. Working on the fix. Best regards, Eduardo -- Eduardo de Barros Lima Software Engineer, Open Virtualization Linux Technology Center - IBM/Brazil eblima@br.ibm.com
participants (5)
-
Chip Vincent
-
Chip Vincent
-
Eduardo Lima (Etrunko)
-
Sharad Mishra
-
Wayne Xia