[PATCH 0 of 3] [TEST] #2 Add RASD template functions, VSMS 14_define_sys_disk.py

This patchset adds functions to get the template RASDs from SDC. These functions should be used to construct the RASDs passed to define system (instead of using the classes defined in vsms.py). This patchset is dependent on a recent version of pywbem.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223515128 25200 # Node ID bbd83da2f0f6bc96ec47025dda3f4f42c095ab86 # Parent cfc2c9d1212d80b4ee2ddf37c5e9398b4e349b26 [TEST] #2 Add get_default_rasds() and get_rasd_templates() to rasd.py NOTE: This patch only works with recent versions of pywbem (svn checkout of 09/04/2008 or later). These functions can be used to get the template RASD instances. Instead of building instances by hand (see default_vssd_rasd_str()), the test cases should be using the template RASDs provided by the SettingsDefineCapabilities association. get_rasd_templates() - returns the min, max, increment, and default template RASD instances for a given AllocationCapabilities instance. get_default_rasds() - returns just the default template RASD instances for the resource pools. Add inst_to_mof() to convert instances to mof format. This is only needed for libcmpiutil version 0.4 and older. Add get_default_rasd_mofs() - returns default template RASDs in mof format. Updates: -Change if/elif in inst_to_mof() to a single if. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r cfc2c9d1212d -r bbd83da2f0f6 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Wed Oct 15 05:57:17 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Wed Oct 08 18:18:48 2008 -0700 @@ -44,3 +44,16 @@ return cn[dash_index+1:] +#FIXME This function is only needed for libcmpiutil versions 0.4 and later. +#Once version 0.4 is obsolete, this function should be removed. +def inst_to_mof(inst): + mof_str = inst.tomof() + + mof_inst = "" + + for str in mof_str.splitlines(): + if str.endswith('{') or str.endswith('};') or not str.endswith('NULL;'): + mof_inst += "%s\n" % str + + return mof_inst + diff -r cfc2c9d1212d -r bbd83da2f0f6 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Oct 15 05:57:17 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Oct 08 18:18:48 2008 -0700 @@ -24,8 +24,11 @@ from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS from XenKvmLib import vxml -from XenKvmLib.classes import get_typed_class - +from XenKvmLib import const +from XenKvmLib.classes import get_typed_class, get_class_type +from XenKvmLib.enumclass import GetInstance +from XenKvmLib.assoc import Associators +from XenKvmLib.const import default_pool_name, default_network_name pasd_cn = 'ProcResourceAllocationSettingData' nasd_cn = 'NetResourceAllocationSettingData' @@ -165,3 +168,63 @@ memrasd_list['VirtualQuantity']) status = FAIL return status + +def get_rasd_templates(host_ip, type, pool_id): + ac_cn = get_typed_class(type, "AllocationCapabilities") + an_cn = get_typed_class(type, "SettingsDefineCapabilities") + + templates = [] + + try: + key_list = {"InstanceID" : pool_id } + + inst = GetInstance(host_ip, ac_cn, key_list) + + temps = Associators(host_ip, an_cn, ac_cn, InstanceID=inst.InstanceID) + + for temp in temps: + templates.append(temp) + + except Exception, detail: + logger.error("Exception: %s", detail) + + return templates + +def get_default_rasds(host_ip, type): + ac_id_list = [ "MemoryPool/0", + "DiskPool/%s" % default_pool_name, + ] + + if type == "LXC": + if const.LXC_netns_support is True: + ac_id_list.append("NetworkPool/%s" % default_network_name) + else: + ac_id_list.append("NetworkPool/%s" % default_network_name) + ac_id_list.append("ProcessorPool/0") + + templates = [] + + for id in ac_id_list: + rasd_list = get_rasd_templates(host_ip, type, id) + if len(rasd_list) < 1: + logger.info("No RASD templates returned for %s", id) + return [] + + for rasd in rasd_list: + if rasd['InstanceID'] == "Default": + templates.append(rasd) + + return templates + +def get_default_rasd_mofs(host_ip, type): + rasds = get_default_rasds(ip, virt) + + rasd_mofs = [] + + #FIXME for libcmpiutil versions 0.4 and later, inst_to_mof() is needed. + #This should be changed to rasd.tomof() once version 0.4 is obsolete. + for rasd in rasds: + rasd_mofs.append(inst_to_mof(rasd)) + + return rasd_mofs +

+1 for me. Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1223515128 25200 # Node ID bbd83da2f0f6bc96ec47025dda3f4f42c095ab86 # Parent cfc2c9d1212d80b4ee2ddf37c5e9398b4e349b26 [TEST] #2 Add get_default_rasds() and get_rasd_templates() to rasd.py
NOTE: This patch only works with recent versions of pywbem (svn checkout of 09/04/2008 or later).
These functions can be used to get the template RASD instances. Instead of building instances by hand (see default_vssd_rasd_str()), the test cases should be using the template RASDs provided by the SettingsDefineCapabilities association.
get_rasd_templates() - returns the min, max, increment, and default template RASD instances for a given AllocationCapabilities instance.
get_default_rasds() - returns just the default template RASD instances for the resource pools.
Add inst_to_mof() to convert instances to mof format. This is only needed for libcmpiutil version 0.4 and older.
Add get_default_rasd_mofs() - returns default template RASDs in mof format.
Updates: -Change if/elif in inst_to_mof() to a single if.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r cfc2c9d1212d -r bbd83da2f0f6 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Wed Oct 15 05:57:17 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Wed Oct 08 18:18:48 2008 -0700 @@ -44,3 +44,16 @@
return cn[dash_index+1:]
+#FIXME This function is only needed for libcmpiutil versions 0.4 and later. +#Once version 0.4 is obsolete, this function should be removed. +def inst_to_mof(inst): + mof_str = inst.tomof() + + mof_inst = "" + + for str in mof_str.splitlines(): + if str.endswith('{') or str.endswith('};') or not str.endswith('NULL;'): + mof_inst += "%s\n" % str + + return mof_inst + diff -r cfc2c9d1212d -r bbd83da2f0f6 suites/libvirt-cim/lib/XenKvmLib/rasd.py --- a/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Oct 15 05:57:17 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/rasd.py Wed Oct 08 18:18:48 2008 -0700 @@ -24,8 +24,11 @@ from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS from XenKvmLib import vxml -from XenKvmLib.classes import get_typed_class - +from XenKvmLib import const +from XenKvmLib.classes import get_typed_class, get_class_type +from XenKvmLib.enumclass import GetInstance +from XenKvmLib.assoc import Associators +from XenKvmLib.const import default_pool_name, default_network_name
pasd_cn = 'ProcResourceAllocationSettingData' nasd_cn = 'NetResourceAllocationSettingData' @@ -165,3 +168,63 @@ memrasd_list['VirtualQuantity']) status = FAIL return status + +def get_rasd_templates(host_ip, type, pool_id): + ac_cn = get_typed_class(type, "AllocationCapabilities") + an_cn = get_typed_class(type, "SettingsDefineCapabilities") + + templates = [] + + try: + key_list = {"InstanceID" : pool_id } + + inst = GetInstance(host_ip, ac_cn, key_list) + + temps = Associators(host_ip, an_cn, ac_cn, InstanceID=inst.InstanceID) + + for temp in temps: + templates.append(temp) + + except Exception, detail: + logger.error("Exception: %s", detail) + + return templates + +def get_default_rasds(host_ip, type): + ac_id_list = [ "MemoryPool/0", + "DiskPool/%s" % default_pool_name, + ] + + if type == "LXC": + if const.LXC_netns_support is True: + ac_id_list.append("NetworkPool/%s" % default_network_name) + else: + ac_id_list.append("NetworkPool/%s" % default_network_name) + ac_id_list.append("ProcessorPool/0") + + templates = [] + + for id in ac_id_list: + rasd_list = get_rasd_templates(host_ip, type, id) + if len(rasd_list) < 1: + logger.info("No RASD templates returned for %s", id) + return [] + + for rasd in rasd_list: + if rasd['InstanceID'] == "Default": + templates.append(rasd) + + return templates + +def get_default_rasd_mofs(host_ip, type): + rasds = get_default_rasds(ip, virt) + + rasd_mofs = [] + + #FIXME for libcmpiutil versions 0.4 and later, inst_to_mof() is needed. + #This should be changed to rasd.tomof() once version 0.4 is obsolete. + for rasd in rasds: + rasd_mofs.append(inst_to_mof(rasd)) + + return rasd_mofs +
_______________________________________________ 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 1224123190 25200 # Node ID 31fca7629bd7f394c3a900c9f20c5573bcedc1f7 # Parent bbd83da2f0f6bc96ec47025dda3f4f42c095ab86 [TEST] Fix VSSD mof generation Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py --- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Oct 15 19:13:10 2008 -0700 @@ -71,8 +71,7 @@ return PASS def test_rasd(options, temp, test_size): - vssd_class = vsms.get_vssd_class(options.virt) - vssd = vssd_class(name=default_dom, virt=options.virt) + vssd = vsms.get_vssd_mof(options.virt, default_dom) drasd_class = vsms.get_dasd_class(options.virt) drasd = drasd_class("hda", temp, default_dom) @@ -81,7 +80,7 @@ mrasd = mrasd_class(name=default_dom, megabytes=32) params = { - "vssd" : vssd.mof(), + "vssd" : vssd, "rasd" : [drasd.mof(), mrasd.mof()] } diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Oct 15 19:13:10 2008 -0700 @@ -51,7 +51,7 @@ name=default_dom) params = { - "vssd" : vssd.mof(), + "vssd" : vssd, "rasd" : [mrasd.mof()], } @@ -101,8 +101,7 @@ def main(): options = main.options - vssd_class = vsms.get_vssd_class(options.virt) - vssd = vssd_class(name=default_dom, virt=options.virt) + vssd = vsms.get_vssd_mof(options.virt, default_dom) status = PASS diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 15 19:13:10 2008 -0700 @@ -108,7 +108,6 @@ self.Kernel = const.Xen_kernel_path self.Ramdisk = const.Xen_init_path - class Xen_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass @@ -118,9 +117,10 @@ class LXC_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass -@eval_cls('VirtualSystemSettingData') -def get_vssd_class(virt): - pass +def get_vssd_mof(virt, dom_name): + vssd_cn = eval(get_typed_class(virt, "VirtualSystemSettingData")) + vssd = vssd_cn(dom_name, virt) + return vssd.mof() # classes to define RASD parameters class CIM_DiskResourceAllocationSettingData(CIMClassMOF): @@ -238,8 +238,7 @@ mem_mb=512, malloc_units="MegaBytes", virt='Xen'): - class_vssd = get_vssd_class(virt) - vssd = class_vssd(name=dom_name, virt=virt) + vssd = get_vssd_mof(virt, dom_name) class_dasd = get_dasd_class(virt) if virt == 'KVM': @@ -261,7 +260,7 @@ # LXC only takes disk and memory device for now. if virt == 'LXC': - return vssd.mof(), [d.mof(), m.mof()] + return vssd, [d.mof(), m.mof()] class_nasd = get_nasd_class(virt) if net_mac != const.Xen_default_mac: @@ -282,5 +281,5 @@ vcpu=proc_vcpu, name=dom_name) - return vssd.mof(), [d.mof(), n.mof(), p.mof(), m.mof()] + return vssd, [d.mof(), n.mof(), p.mof(), m.mof()] diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Oct 15 19:13:10 2008 -0700 @@ -466,7 +466,7 @@ net_type, net_name, net_mac, vcpus, mem, mem_allocunits): self.virt = virt self.domain_name = dom_name - self.vssd = vsms.get_vssd_class(virt)(name=dom_name, virt=virt) + self.vssd = vsms.get_vssd_mof(virt, dom_name) self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source, dom_name) self.nasd = vsms.get_nasd_class(virt)(type=net_type, mac=net_mac,

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1224123190 25200 # Node ID 31fca7629bd7f394c3a900c9f20c5573bcedc1f7 # Parent bbd83da2f0f6bc96ec47025dda3f4f42c095ab86 [TEST] Fix VSSD mof generation
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py --- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Oct 15 19:13:10 2008 -0700 @@ -71,8 +71,7 @@ return PASS
def test_rasd(options, temp, test_size): - vssd_class = vsms.get_vssd_class(options.virt) - vssd = vssd_class(name=default_dom, virt=options.virt) + vssd = vsms.get_vssd_mof(options.virt, default_dom)
drasd_class = vsms.get_dasd_class(options.virt) drasd = drasd_class("hda", temp, default_dom) @@ -81,7 +80,7 @@ mrasd = mrasd_class(name=default_dom, megabytes=32)
params = { - "vssd" : vssd.mof(), + "vssd" : vssd, "rasd" : [drasd.mof(), mrasd.mof()] }
diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/11_define_memrasdunits.py Wed Oct 15 19:13:10 2008 -0700 @@ -51,7 +51,7 @@ name=default_dom)
params = { - "vssd" : vssd.mof(), + "vssd" : vssd, "rasd" : [mrasd.mof()], }
@@ -101,8 +101,7 @@ def main(): options = main.options
- vssd_class = vsms.get_vssd_class(options.virt) - vssd = vssd_class(name=default_dom, virt=options.virt) + vssd = vsms.get_vssd_mof(options.virt, default_dom)
status = PASS
diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 15 19:13:10 2008 -0700 @@ -108,7 +108,6 @@ self.Kernel = const.Xen_kernel_path self.Ramdisk = const.Xen_init_path
- class Xen_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass
@@ -118,9 +117,10 @@ class LXC_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass
-@eval_cls('VirtualSystemSettingData') -def get_vssd_class(virt): - pass +def get_vssd_mof(virt, dom_name): + vssd_cn = eval(get_typed_class(virt, "VirtualSystemSettingData")) + vssd = vssd_cn(dom_name, virt)
I did not get the difference between vssd_cn and vssd assignments, both of them evaluate to classobj XenKvmLib.vsms.Xen_VirtualSystemSettingData.
+ return vssd.mof()
# classes to define RASD parameters class CIM_DiskResourceAllocationSettingData(CIMClassMOF): @@ -238,8 +238,7 @@ mem_mb=512, malloc_units="MegaBytes", virt='Xen'): - class_vssd = get_vssd_class(virt) - vssd = class_vssd(name=dom_name, virt=virt) + vssd = get_vssd_mof(virt, dom_name)
class_dasd = get_dasd_class(virt) if virt == 'KVM': @@ -261,7 +260,7 @@
# LXC only takes disk and memory device for now. if virt == 'LXC': - return vssd.mof(), [d.mof(), m.mof()] + return vssd, [d.mof(), m.mof()]
class_nasd = get_nasd_class(virt) if net_mac != const.Xen_default_mac: @@ -282,5 +281,5 @@ vcpu=proc_vcpu, name=dom_name)
- return vssd.mof(), [d.mof(), n.mof(), p.mof(), m.mof()] + return vssd, [d.mof(), n.mof(), p.mof(), m.mof()]
diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Oct 15 19:13:10 2008 -0700 @@ -466,7 +466,7 @@ net_type, net_name, net_mac, vcpus, mem, mem_allocunits): self.virt = virt self.domain_name = dom_name - self.vssd = vsms.get_vssd_class(virt)(name=dom_name, virt=virt) + self.vssd = vsms.get_vssd_mof(virt, dom_name) self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source, dom_name) self.nasd = vsms.get_nasd_class(virt)(type=net_type, mac=net_mac,
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

diff -r bbd83da2f0f6 -r 31fca7629bd7 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 08 18:18:48 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 15 19:13:10 2008 -0700 @@ -108,7 +108,6 @@ self.Kernel = const.Xen_kernel_path self.Ramdisk = const.Xen_init_path - class Xen_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass
@@ -118,9 +117,10 @@ class LXC_VirtualSystemSettingData(CIM_VirtualSystemSettingData): pass
-@eval_cls('VirtualSystemSettingData') -def get_vssd_class(virt): - pass +def get_vssd_mof(virt, dom_name): + vssd_cn = eval(get_typed_class(virt, "VirtualSystemSettingData")) + vssd = vssd_cn(dom_name, virt)
I did not get the difference between vssd_cn and vssd assignments, both of them evaluate to classobj XenKvmLib.vsms.Xen_VirtualSystemSettingData.
+ return vssd.mof()
If you print vssd_cn, you'll get: XenKvmLib.vsms.KVM_VirtualSystemSettingData If you print vssd, you'll get mof syntax. ================================ To see why this change is needed, you can apply the following patch. Run it once with: return vssd #return vssd.mof() Then run it again with #return vssd return vssd.mof() In the first case, the VSSD object is: <XenKvmLib.vsms.KVM_VirtualSystemSettingData instance at 0x217a320> In the second, it's a properly formatted MOF, which is what the CIMOM is expecting. # HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1224271624 25200 # Node ID 93edf76620526b54e527de006ad3c2d587c725a3 # Parent 16ed883b2d333bfe73059c319b011e5fe6153ae8 Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 16ed883b2d33 -r 93edf7662052 lib/CimTest/CimExt.py --- a/lib/CimTest/CimExt.py Wed Oct 15 19:13:10 2008 -0700 +++ b/lib/CimTest/CimExt.py Fri Oct 17 12:27:04 2008 -0700 @@ -29,6 +29,8 @@ return _Method(self.__invoker, "%s.%s" % (self.__name, name)) def __call__(self, **args): + print "\n" + print args return self.__invoker(self.__name, args) diff -r 16ed883b2d33 -r 93edf7662052 suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Oct 15 19:13:10 2008 -0700 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Fri Oct 17 12:27:04 2008 -0700 @@ -92,6 +92,7 @@ destroy_and_undefine_domain(test_dom, options.ip, options.virt) + return FAIL return status if __name__ == "__main__": diff -r 16ed883b2d33 -r 93edf7662052 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Oct 15 19:13:10 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri Oct 17 12:27:04 2008 -0700 @@ -119,8 +119,14 @@ def get_vssd_mof(virt, dom_name): vssd_cn = eval(get_typed_class(virt, "VirtualSystemSettingData")) + print vssd_cn + print "\n" vssd = vssd_cn(dom_name, virt) - return vssd.mof() + print vssd + print "\n" + print vssd.mof() + return vssd + #return vssd.mof() # classes to define RASD parameters class CIM_DiskResourceAllocationSettingData(CIMClassMOF): -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1224123190 25200 # Node ID 16ed883b2d333bfe73059c319b011e5fe6153ae8 # Parent 31fca7629bd7f394c3a900c9f20c5573bcedc1f7 [TEST] #2 Add VirtualSystemManagementService - 14_define_sys_disk.py This test defines a guest with a very large disk image. This test can be updated in the future to include other disk specific DefineSystem() tests. Updates: -Remove call to default_vssd_rasd_str(); replace with call to get_vssd_mof() Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 31fca7629bd7 -r 16ed883b2d33 suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Oct 15 19:13:10 2008 -0700 @@ -0,0 +1,99 @@ +#!/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 os +from VirtLib.utils import run_remote +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import do_main, _image_dir +from XenKvmLib.common_util import create_using_definesystem +from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.rasd import get_default_rasds +from XenKvmLib.vsms import get_vssd_mof + +sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +test_dom = 'rstest_disk_domain' + +def make_long_disk_path(ip): + path = os.path.join(_image_dir, 'cimtest_large_image') + + cmd = "dd if=/dev/zero of=%s bs=1M count=1 seek=8192" % path + + rc, out = run_remote(ip, cmd) + if rc != 0: + logger.error("Unable to create large disk image") + logger.error(out) + return None + + return path + +def get_vssd_rasd(ip, virt, addr): + vssd = get_vssd_mof(virt, test_dom) + + rasds = get_default_rasds(ip, virt) + + for i in range(0, len(rasds)): + if rasds[i]['PoolID'].find('DiskPool') >= 0: + rasds[i]['Address'] = addr + rasds[i] = inst_to_mof(rasds[i]) + + params = { 'vssd' : vssd, + 'rasd' : rasds + } + + return params + +@do_main(sup_types) +def main(): + options = main.options + + try: + addr = make_long_disk_path(options.ip) + if addr is None: + raise Exception("Unable to create large disk image") + + define_params = get_vssd_rasd(options.ip, options.virt, addr) + if len(define_params) != 2: + raise Exception("Unable to get VSSD and RASDs for %s" % test_dom) + + status = create_using_definesystem(test_dom, options.ip, + params=define_params, ref_config="", + virt=options.virt) + if status != PASS: + raise Exception("Unable to define %s" % test_dom) + + except Exception, details: + logger.error(details) + status = FAIL + + if os.path.exists(addr): + os.remove(addr) + + destroy_and_undefine_domain(test_dom, options.ip, options.virt) + + return status + +if __name__ == "__main__": + sys.exit(main()) +

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1224123190 25200 # Node ID 16ed883b2d333bfe73059c319b011e5fe6153ae8 # Parent 31fca7629bd7f394c3a900c9f20c5573bcedc1f7 [TEST] #2 Add VirtualSystemManagementService - 14_define_sys_disk.py
This test defines a guest with a very large disk image. This test can be updated in the future to include other disk specific DefineSystem() tests.
Updates: -Remove call to default_vssd_rasd_str(); replace with call to get_vssd_mof()
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 31fca7629bd7 -r 16ed883b2d33 suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Oct 15 19:13:10 2008 -0700 @@ -0,0 +1,99 @@ +#!/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 os +from VirtLib.utils import run_remote +from CimTest.Globals import logger +from CimTest.ReturnCodes import FAIL, PASS +from XenKvmLib.const import do_main, _image_dir +from XenKvmLib.common_util import create_using_definesystem +from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.classes import get_typed_class, inst_to_mof +from XenKvmLib.rasd import get_default_rasds +from XenKvmLib.vsms import get_vssd_mof + +sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] +test_dom = 'rstest_disk_domain' + +def make_long_disk_path(ip): + path = os.path.join(_image_dir, 'cimtest_large_image') + + cmd = "dd if=/dev/zero of=%s bs=1M count=1 seek=8192" % path + + rc, out = run_remote(ip, cmd) + if rc != 0: + logger.error("Unable to create large disk image") + logger.error(out) + return None + + return path + +def get_vssd_rasd(ip, virt, addr): + vssd = get_vssd_mof(virt, test_dom) + + rasds = get_default_rasds(ip, virt) + + for i in range(0, len(rasds)):
I think we had discussed this to be "for i in range(len(rasds))" :) For now we can leave this as it is.
+ if rasds[i]['PoolID'].find('DiskPool') >= 0:
This can be "if 'DiskPool' in rasds[i]['PoolID']" as an alternative. But the above what you have also serves our purpose. +1 for me for the changes.
+ rasds[i]['Address'] = addr + rasds[i] = inst_to_mof(rasds[i]) + + params = { 'vssd' : vssd, + 'rasd' : rasds + } + + return params + +@do_main(sup_types) +def main(): + options = main.options + + try: + addr = make_long_disk_path(options.ip) + if addr is None: + raise Exception("Unable to create large disk image") + + define_params = get_vssd_rasd(options.ip, options.virt, addr) + if len(define_params) != 2: + raise Exception("Unable to get VSSD and RASDs for %s" % test_dom) + + status = create_using_definesystem(test_dom, options.ip, + params=define_params, ref_config="", + virt=options.virt) + if status != PASS: + raise Exception("Unable to define %s" % test_dom) + + except Exception, details: + logger.error(details) + status = FAIL + + if os.path.exists(addr): + os.remove(addr) + + destroy_and_undefine_domain(test_dom, 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

+ + rasds = get_default_rasds(ip, virt) + + for i in range(0, len(rasds)):
I think we had discussed this to be "for i in range(len(rasds))" :) For now we can leave this as it is.
Yes, sorry about that. You did mention it in your other review, but I forgot.
+ if rasds[i]['PoolID'].find('DiskPool') >= 0:
This can be "if 'DiskPool' in rasds[i]['PoolID']" as an alternative. But the above what you have also serves our purpose. +1 for me for the changes.
Your way is cleaner. I'll apply this set and then follow up with a patch to fix these items. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert