[PATCH] [TEST] #7 Add new test to verify enum of DiskRASD to have EmulatedType=0 for Disk and EmulatedType=1 for CDROM
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1231210158 28800
# Node ID b592961ccaac67ad3cfd8876beb22beec0c28492
# Parent 64b84ef28b22d17dd22027c632a9dc44d642d2b5
[TEST] #7 Add new test to verify enum of DiskRASD to have EmulatedType=0 for Disk and EmulatedType=1 for CDROM
Updates form 6 to 7:
Correct exception description
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 64b84ef28b22 -r b592961ccaac suites/libvirt-cim/cimtest/RASD/05_disk_rasd_emu_type.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/RASD/05_disk_rasd_emu_type.py Mon Jan 05 18:49:18 2009 -0800
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Guolian Yun <yunguol(a)cn.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
+from XenKvmLib.enumclass import EnumInstances
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.common_util import parse_instance_id
+from XenKvmLib.const import do_main
+from XenKvmLib.vxml import get_class
+from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.Globals import logger
+from XenKvmLib.const import get_provider_version
+
+SUPPORTED_TYPES = ['KVM']
+default_dom = 'test_domain'
+libvirt_em_type_changeset = 737
+
+@do_main(SUPPORTED_TYPES)
+def main():
+ status = FAIL
+ options = main.options
+ curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+ if curr_cim_rev < libvirt_em_type_changeset:
+ return SKIP
+
+ emu_types = [0, 1]
+ try:
+ for exp_emu_type in emu_types:
+ cxml = get_class(options.virt)(default_dom, emu_type=exp_emu_type)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Failed to call DefineSystem()")
+ return FAIL
+
+ drasd= get_typed_class(options.virt,'DiskResourceAllocationSettingData')
+
+ drasd_list = EnumInstances(options.ip, drasd, ret_cim_inst=True)
+ if len(drasd_list) < 1:
+ raise Exception("%s returned %i instances, expected at least 1" \
+ %(drasd, len(drasd_list)))
+
+ found_rasd = None
+ for rasd in drasd_list:
+ guest, dev, status = parse_instance_id(rasd['InstanceID'])
+ if status != PASS:
+ raise Exception("Unable to parse InstanceID: %s" \
+ % rasd['InstanceID'])
+ if guest == default_dom:
+ if rasd['EmulatedType'] == exp_emu_type:
+ found_rasd = rasd
+ status = PASS
+ break
+ else:
+ raise Exception("EmulatedType Mismatch: got %d,"
+ "expected %d" %(rasd['EmulatedType'],
+ exp_emu_type))
+
+ if found_rasd is None:
+ raise Exception("DiskRASD for defined dom was not found")
+ except Exception, detail:
+ logger.error("Exception: %s", detail)
+ status = FAIL
+
+ cxml.undefine(options.ip)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
diff -r 64b84ef28b22 -r b592961ccaac suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Tue Dec 30 00:58:06 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jan 05 18:49:18 2009 -0800
@@ -126,8 +126,10 @@
# classes to define RASD parameters
class CIM_DiskResourceAllocationSettingData(CIMClassMOF):
- def __init__(self, dev, source, name):
+ def __init__(self, dev, source, name, emu_type=None):
self.ResourceType = RASD_TYPE_DISK
+ if emu_type != None:
+ self.EmulatedType = emu_type
if dev != None:
self.VirtualDevice = dev
self.InstanceID = '%s/%s' % (name, dev)
@@ -239,6 +241,7 @@
proc_vcpu=1,
mem_mb=512,
malloc_units="MegaBytes",
+ emu_type=None,
virt='Xen'):
vssd = get_vssd_mof(virt, dom_name)
@@ -252,7 +255,7 @@
elif virt == 'LXC':
disk_dev = const.LXC_default_mp
disk_source = const.LXC_default_source
- d = class_dasd(disk_dev, disk_source, dom_name)
+ d = class_dasd(disk_dev, disk_source, dom_name, emu_type)
class_masd = get_masd_class(virt)
m = class_masd(
diff -r 64b84ef28b22 -r b592961ccaac suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Dec 30 00:58:06 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 05 18:49:18 2009 -0800
@@ -466,11 +466,13 @@
class VirtCIM:
def __init__(self, virt, dom_name, disk_dev, disk_source,
- net_type, net_name, net_mac, vcpus, mem, mem_allocunits):
+ net_type, net_name, net_mac, vcpus, mem,
+ mem_allocunits, emu_type):
self.virt = virt
self.domain_name = dom_name
self.vssd = vsms.get_vssd_mof(virt, dom_name)
- self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source, dom_name)
+ self.dasd = vsms.get_dasd_class(virt)(disk_dev, disk_source,
+ dom_name, emu_type)
self.nasd = vsms.get_nasd_class(virt)(type=net_type,
mac=net_mac,
name=dom_name,
@@ -687,13 +689,15 @@
disk_file_path=const.KVM_disk_path,
disk=const.KVM_default_disk_dev,
ntype=const.default_net_type,
- net_name=const.default_network_name):
+ net_name=const.default_network_name,
+ emu_type=None):
if not os.path.exists(disk_file_path):
logger.error('Error: Disk image does not exist')
sys.exit(1)
VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus)
VirtCIM.__init__(self, 'KVM', test_dom, disk, disk_file_path,
- ntype, net_name, mac, vcpus, mem, mem_allocunits)
+ ntype, net_name, mac, vcpus, mem,
+ mem_allocunits, emu_type)
self._os()
self._devices(const.KVM_default_emulator, ntype,
disk_file_path, disk, mac, net_name)
15 years, 9 months
[PATCH] This patch advertises the Allocation Capabilities Profile and the Resource Allocation Profile
by Richard Maciel
# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1231536014 7200
# Node ID 85adb98a1f73de69432e84faf6ef338d29fbfca7
# Parent 3557859610b4eaf8a2bdcb28d7002121e3e776b1
This patch advertises the Allocation Capabilities Profile and the Resource Allocation Profile
* Added two new reg_prof instances that represent the added profiles
Signed-off-by: Richard Maciel <richardm(a)br.ibm.com>
diff -r 3557859610b4 -r 85adb98a1f73 src/profiles.h
--- a/src/profiles.h Wed Dec 10 12:42:02 2008 -0800
+++ b/src/profiles.h Fri Jan 09 19:20:14 2009 -0200
@@ -114,6 +114,26 @@
.scoping_profile = &SystemVirtualization
};
+struct reg_prof AllocationCapabilities = {
+ .reg_org = 2,
+ .reg_id = "CIM:DSP1043-AllocationCapabilities-1.0.0a",
+ .reg_name = "Allocation Capabilities",
+ .reg_version = "1.0.0a",
+ .scoping_class = "ComputerSystem",
+ .central_class = "AllocationCapabilities",
+ .scoping_profile = &SystemVirtualization
+};
+
+struct reg_prof ResourceAllocation = {
+ .reg_org = 2,
+ .reg_id = "CIM:DSP1041-ResourceAllocation-1.1.0c",
+ .reg_name = "Resource Allocation",
+ .reg_version = "1.1.0c",
+ .scoping_class = "ComputerSystem",
+ .central_class = "ResourcePool",
+ .scoping_profile = &SystemVirtualization
+};
+
// Make sure to add pointer to your reg_prof struct here.
struct reg_prof *profiles[] = {
&SystemVirtualization,
@@ -124,6 +144,8 @@
&MemoryResourceVirtualization,
&VirtualSystemMigration,
&KVMRedirection,
+ &AllocationCapabilities,
+ &ResourceAllocation,
NULL
};
15 years, 9 months
[PATCH] [TEST] #2 Update RASD -t 04_disk_rasd_size.py to user cim_define()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231455763 28800
# Node ID ea39f5d207a8fbade59995cd5041a10cb58b0aa0
# Parent 59af62c3ec5696d019e505a05032616af9b12fcd
[TEST] #2 Update RASD -t 04_disk_rasd_size.py to user cim_define()
Also, reorganize the test slighly so that there's no need to pass cxml to a
function for the define call.
Updates:
-Improve error message
-Fixed some formatting issues
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 59af62c3ec56 -r ea39f5d207a8 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py
--- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Thu Jan 08 14:36:28 2009 -0800
+++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Thu Jan 08 15:02:43 2009 -0800
@@ -29,11 +29,9 @@
from XenKvmLib.const import do_main
from CimTest.Globals import logger
from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
-from XenKvmLib import vsms
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
+from XenKvmLib.vxml import get_class
def make_image(ip, size):
s, fn = utils.run_remote(ip, "mktemp")
@@ -54,52 +52,22 @@
def check_rasd_size(rasd, size):
if rasd["AllocationUnits"] != "Bytes":
- logger.error("AllocationUnits != Bytes?")
+ logger.error("Got %s units, exp Bytes", rasd["AllocationUnits"])
return FAIL
try:
cim_size = int(rasd["VirtualQuantity"])
- except Exception, e:
- logger.error("Failed to get DiskRASD size: %s" % e)
+ except Exception, details:
+ logger.error("Failed to get DiskRASD size: %s" % details)
return FAIL
if cim_size != size:
- logger.error("CIM reports %i bytes, but should be %i bytes" % (cim_size,
- size))
+ logger.error("CIM reports %i bytes, but should be %i bytes", cim_size,
+ size)
return FAIL
- else:
- logger.info("Verified %i bytes" % cim_size)
- return PASS
-def test_rasd(options, temp, test_size):
- vssd = vsms.get_vssd_mof(options.virt, default_dom)
-
- drasd_class = vsms.get_dasd_class(options.virt)
- drasd = drasd_class("hda", temp, default_dom)
-
- mrasd_class = vsms.get_masd_class(options.virt)
- mrasd = mrasd_class(name=default_dom, megabytes=32)
-
- params = {
- "vssd" : vssd,
- "rasd" : [drasd.mof(), mrasd.mof()]
- }
-
- create_using_definesystem(default_dom,
- options.ip,
- params=params,
- virt=options.virt)
-
- cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
- rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
-
- status = FAIL
- for rasd in rasds:
- if rasd["Address"] == temp:
- status = check_rasd_size(rasd, test_size)
- break
-
- return status
+ logger.info("Verified %i bytes" % cim_size)
+ return PASS
@do_main(sup_types)
def main():
@@ -113,14 +81,30 @@
return FAIL
logger.info("Created temp disk %s of size %i bytes" % (temp, test_size))
+
+ virtxml = get_class(options.virt)
+ cxml = virtxml(default_dom, mem=32, disk_file_path=temp, disk="hda")
try:
- status = test_rasd(options, temp, test_size)
- except Exception, e:
- logger.error("Failed to test RASD: %s" % e)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ raise Exception("Failed to define the dom: %s" % default_dom)
- undefine_test_domain(default_dom, options.ip, options.virt)
+ cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
+ rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
+
+ status = FAIL
+ for rasd in rasds:
+ if rasd["Address"] == temp:
+ status = check_rasd_size(rasd, test_size)
+ break
+
+ except Exception, details:
+ logger.error("Failed to test RASD: %s" % details)
+ status = FAIL
+
kill_image(options.ip, temp)
+ cxml.undefine(options.ip)
return status
15 years, 9 months
[PATCH] [TEST] #3 Update VSMS 01_definesystem_name.py to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231441895 28800
# Node ID 38811eb854a1c52be94d7e8440c2272b94b70708
# Parent 840f4651f746882475188adba781fafbf583c07b
[TEST] #3 Update VSMS 01_definesystem_name.py to use cim_() functions
Updates from 2 to 3:
-In case of an error, use logger.error not logger.info
Updates from 1 to 2:
-Added cim_destroy() to destroy the guest at the end of the test
-Reworded log message for clarity
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 840f4651f746 -r 38811eb854a1 suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Tue Jan 06 11:56:13 2009 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Thu Jan 08 11:11:35 2009 -0800
@@ -23,12 +23,10 @@
#
import sys
-import pywbem
-from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
from XenKvmLib.const import do_main
from CimTest.Globals import logger
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.vxml import get_class
SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
default_dom = 'test_domain'
@@ -37,10 +35,19 @@
def main():
options = main.options
- status = create_using_definesystem(default_dom, options.ip,
- virt=options.virt)
- undefine_test_domain(default_dom, options.ip,
- virt=options.virt)
+ cxml = get_class(options.virt)(default_dom)
+
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Unable to define %s" % default_dom)
+ return FAIL
+
+ status = cxml.cim_start(options.ip)
+ if status != PASS:
+ logger.error("Failed to start the defined domain: %s" % default_dom)
+
+ cxml.cim_destroy(options.ip)
+ cxml.undefine(options.ip)
return status
15 years, 9 months
[PATCH] [TEST] Update VSMS 04_definesystem_ers.py to use cim_define()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231351832 28800
# Node ID a320568c9308dc0d42c8fe46a7aad0f3ff699260
# Parent 64672f2644fb26a6788f171685269e59b9029142
[TEST] Update VSMS 04_definesystem_ers.py to use cim_define()
Add a err_rc and err_desc elements to the VirtCIM class. This will allow
us to check the error code and error description in case of failed CIM
method calls.
Add two functions: set_sys_settings() and set_res_settings(). These allow the
caller to set the VSSD and RASDs after the initial init() of the VirtCIM class.
Some of the logic in cim_define() was changed to allow the passing of just
a single RASD to DefineSystem() (instead of passing all the RASDs).
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 64672f2644fb -r a320568c9308 suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py Wed Jan 07 10:10:00 2009 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/04_definesystem_ers.py Wed Jan 07 10:10:32 2009 -0800
@@ -23,17 +23,14 @@
#
import sys
-import pywbem
-from VirtLib import utils
-from XenKvmLib import vsms
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
+from pywbem import CIM_ERR_FAILED
from CimTest.Globals import logger
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.vxml import get_class
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
-exp_rc = 1 #CMPI_RC_ERR_FAILED
+exp_rc = CIM_ERR_FAILED
exp_desc = 'Unable to parse embedded object'
@do_main(sup_types)
@@ -41,26 +38,34 @@
options = main.options
dname = 'test_domain'
- vssd, rasd = vsms.default_vssd_rasd_str(dom_name=dname, virt=options.virt)
- params = {'vssd' : vssd,
- 'rasd' : ['wrong']
- }
+ cxml = get_class(options.virt)(dname)
- exp_err = {'exp_rc' : exp_rc,
- 'exp_desc' : exp_desc
- }
+ rasd_list = { "MemResourceAllocationSettingData" : "wrong" }
+ cxml.set_res_settings(rasd_list)
+ ret = cxml.cim_define(options.ip)
+ if ret:
+ logger.error('DefineSystem should NOT return OK with a wrong ss input')
+ status = FAIL
- rc = create_using_definesystem(dname, options.ip, params, ref_config=' ',
- exp_err=exp_err, virt=options.virt)
+ try:
+ if int(cxml.err_rc) != exp_rc:
+ raise Exception("Got rc: %d, exp %d." % (int(cxml.err_rc), exp_rc))
- if rc != PASS:
- logger.error('DefineSystem should NOT return OK with a wrong ss input')
+ if cxml.err_desc.find(exp_desc) < 0:
+ raise Exception("Got desc: '%s', exp '%s'" % (cxml.err_desc,
+ exp_desc))
- undefine_test_domain(dname, options.ip, virt=options.virt)
+ status = PASS
- return rc
+ except Exception, details:
+ logger.error(details)
+ status = FAIL
+
+ cxml.undefine(options.ip)
+
+ return status
if __name__ == "__main__":
sys.exit(main())
diff -r 64672f2644fb -r a320568c9308 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jan 07 10:10:00 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jan 07 10:10:32 2009 -0800
@@ -469,6 +469,8 @@
net_type, net_name, net_mac, vcpus, mem, mem_allocunits):
self.virt = virt
self.domain_name = dom_name
+ self.err_rc = None
+ self.err_desc = None
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,
@@ -487,11 +489,17 @@
def cim_define(self, ip, ref_conf=None):
service = vsms.get_vsms_class(self.virt)(ip)
sys_settings = str(self.vssd)
- if self.virt == 'LXC' and const.LXC_netns_support is False:
- res_settings = [str(self.dasd), str(self.pasd), str(self.masd)]
- else:
- res_settings = [str(self.dasd), str(self.nasd),
- str(self.pasd), str(self.masd)]
+
+ res_settings = []
+ if self.dasd is not None:
+ res_settings.append(str(self.dasd))
+ if self.pasd is not None:
+ res_settings.append(str(self.pasd))
+ if self.masd is not None:
+ res_settings.append(str(self.masd))
+ if self.nasd is not None or \
+ (self.virt == 'LXC' and const.LXC_netns_support is False):
+ res_settings.append(str(self.nasd))
if ref_conf is None:
ref_conf = ' '
@@ -502,6 +510,8 @@
ReferenceConfiguration=ref_conf)
except pywbem.CIMError, (rc, desc):
logger.error('Got CIM error %s with return code %s' % (desc, rc))
+ self.err_rc = rc
+ self.err_desc = desc
return False
except Exception, details:
@@ -519,6 +529,12 @@
target = pywbem.cim_obj.CIMInstanceName(cs_cn, keybindings = keys)
try:
ret = service.DestroySystem(AffectedSystem=target)
+ except pywbem.CIMError, (rc, desc):
+ logger.error('Got CIM error %s with return code %s' % (desc, rc))
+ self.err_rc = rc
+ self.err_desc = desc
+ return False
+
except Exception, details:
logger.error('Error invoking DestroySystem')
logger.error('Got error %s with exception %s' \
@@ -570,6 +586,12 @@
cs.RequestStateChange(RequestedState=req_state_change,
TimeoutPeriod=time_period)
+ except pywbem.CIMError, (rc, desc):
+ logger.error('Got CIM error %s with return code %s' % (desc, rc))
+ self.err_rc = rc
+ self.err_desc = desc
+ return FAIL
+
except Exception, detail:
logger.error("In fn cim_state_change()")
logger.error("Failed to change state of the domain '%s'", cs.Name)
@@ -615,6 +637,19 @@
return self.cim_state_change(server, const.CIM_RESET,
req_time, poll_time, const.CIM_ENABLE)
+ def set_sys_settings(self, vssd):
+ self.vssd = vssd
+
+ def set_res_settings(self, rasd_list):
+ for cn, rasd in rasd_list.iteritems():
+ if cn.find("MemResourceAllocationSettingData") >= 0:
+ self.masd = rasd
+ elif cn.find("ProcResourceAllocationSettingData") >= 0:
+ self.pasd = rasd
+ elif cn.find("DiskResourceAllocationSettingData") >= 0:
+ self.dasd = rasd
+ elif cn.find("NetResourceAllocationSettingData") >= 0:
+ self.nasd = rasd
class XenXML(VirtXML, VirtCIM):
15 years, 9 months
[PATCH] [TEST] Update 32_start_reboot.py to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231194787 28800
# Node ID f317d11f46a29a8141563498076d716153dfc5f2
# Parent ae40dfa1b8f6e134d200233d2e5b3395855cafa2
[TEST] Update 32_start_reboot.py to use cim_() functions
Also change cim_state_change() to support enable and requested state parameters.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ae40dfa1b8f6 -r f317d11f46a2 suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Jan 05 14:08:38 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Jan 05 14:33:07 2009 -0800
@@ -28,26 +28,13 @@
# The test is considered to be successful if RequestedState Property
# has a value of 10 when the VS is moved from active to reboot state.
#
-# List of Valid state values (Refer to VSP spec doc Table 2 for more)
-# ---------------------------------
-# State | Values
-# ---------------------------------
-# Defined | 3
-# Active | 2
-# Rebooted | 10
-#
# Date: 03-03-2008
import sys
-from VirtLib import utils
-from time import sleep
from CimTest.Globals import logger
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
-from XenKvmLib.test_doms import destroy_and_undefine_domain
-from XenKvmLib.common_util import create_using_definesystem, \
- call_request_state_change, \
- poll_for_state_change
+from XenKvmLib.vxml import get_class
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
@@ -64,45 +51,35 @@
server = options.ip
virt = options.virt
- tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \
- ('Reboot', [ACTIVE_STATE, REBOOT_STATE])]
-
+ action_failed = False
try:
# define the vs
- status = create_using_definesystem(default_dom, server,
- virt=virt)
+ cxml = get_class(virt)(default_dom)
+ ret = cxml.cim_define(server)
+ if not ret:
+ raise Exception("Failed to define the guest: %s" % default_dom)
+
+ status = cxml.cim_start(server)
if status != PASS:
- logger.error("Unable to define domain '%s' using DefineSystem()",
- default_dom)
- return status
+ action_failed = True
+ raise Exception("Unable start dom '%s'" % default_dom)
- # start, then reboot
- for action, state in tc_scen:
- en_state = state[0]
- rq_state = state[1]
- status = call_request_state_change(default_dom, server,
- rq_state, TIME,
- virt=virt)
- if status != PASS:
- logger.error("Unable to '%s' dom '%s' using RequestedStateChange()",
- action, default_dom)
- status = XFAIL_RC(bug_libvirt)
- break
-
- status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
- timeout=10)
-
- if status != PASS or dom_cs.RequestedState != rq_state:
- status = FAIL
- logger.error("Attributes for dom '%s' is not set as expected.",
- default_dom)
- break
+ status = cxml.cim_reboot(server)
+ if status != PASS:
+ action_failed = True
+ raise Exception("Unable reboot dom '%s'" % default_dom)
except Exception, detail:
logger.error("Exception: %s", detail)
status = FAIL
- destroy_and_undefine_domain(default_dom, server, virt)
+ cxml.cim_destroy(server)
+ cxml.undefine(server)
+
+ if action_failed:
+ if virt == "KVM" or virt == "LXC":
+ return XFAIL_RC(bug_libvirt)
+
return status
if __name__ == "__main__":
diff -r ae40dfa1b8f6 -r f317d11f46a2 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 05 14:08:38 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 05 14:33:07 2009 -0800
@@ -535,7 +535,7 @@
try:
cs = GetInstance(server, cs_class, keys)
- if cs.Name != self.domain_name:
+ if cs is None or cs.Name != self.domain_name:
raise Exception("Wrong guest instance")
if cs.EnabledState != en_state:
@@ -553,7 +553,11 @@
return PASS
- def cim_state_change(self, server, req_state, req_timeout, poll_time):
+ def cim_state_change(self, server, req_state, req_timeout, poll_time,
+ en_state=None):
+ if en_state is None:
+ en_state = req_state
+
cs = None
cs_class = get_typed_class(self.virt, 'ComputerSystem')
keys = { 'Name' : self.domain_name, 'CreationClassName' : cs_class }
@@ -562,7 +566,7 @@
return status
try:
- req_state_change = pywbem.cim_types.Uint16(req_state)
+ req_state_change = pywbem.cim_types.Uint16(req_state)
time_period = pywbem.cim_types.CIMDateTime(req_timeout)
cs.RequestStateChange(RequestedState=req_state_change,
TimeoutPeriod=time_period)
@@ -574,7 +578,7 @@
return FAIL
for i in range(1, (poll_time + 1)):
- status = self.check_guest_state(server, req_state)
+ status = self.check_guest_state(server, en_state, req_state)
if status == PASS:
break
@@ -606,7 +610,7 @@
def cim_reboot(self, server, req_time=const.TIME, poll_time=30):
return self.cim_state_change(server, const.CIM_REBOOT,
- req_time, poll_time)
+ req_time, poll_time, const.CIM_ENABLE)
def cim_reset(self, server, req_time=const.TIME, poll_time=30):
return self.cim_state_change(server, const.CIM_RESET,
15 years, 9 months
[PATCH] [TEST] Update RASD -t 04_disk_rasd_size.py to user cim_define()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231350675 28800
# Node ID f0ebc2def018b3d34a897762e249e922ca44f71f
# Parent 0e5943129dc448a12b0cb8c382afbdcc61d89a7a
[TEST] Update RASD -t 04_disk_rasd_size.py to user cim_define()
Also, reorganize the test slighly so that there's no need to pass cxml to a
function for the define call.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 0e5943129dc4 -r f0ebc2def018 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py
--- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Jan 07 09:51:11 2009 -0800
+++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py Wed Jan 07 09:51:15 2009 -0800
@@ -29,11 +29,9 @@
from XenKvmLib.const import do_main
from CimTest.Globals import logger
from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
-from XenKvmLib import vsms
from XenKvmLib import enumclass
from XenKvmLib.classes import get_typed_class
+from XenKvmLib.vxml import get_class
def make_image(ip, size):
s, fn = utils.run_remote(ip, "mktemp")
@@ -59,47 +57,17 @@
try:
cim_size = int(rasd["VirtualQuantity"])
- except Exception, e:
- logger.error("Failed to get DiskRASD size: %s" % e)
+ except Exception, details:
+ logger.error("Failed to get DiskRASD size: %s" % details)
return FAIL
if cim_size != size:
logger.error("CIM reports %i bytes, but should be %i bytes" % (cim_size,
size))
return FAIL
- else:
- logger.info("Verified %i bytes" % cim_size)
- return PASS
-def test_rasd(options, temp, test_size):
- vssd = vsms.get_vssd_mof(options.virt, default_dom)
-
- drasd_class = vsms.get_dasd_class(options.virt)
- drasd = drasd_class("hda", temp, default_dom)
-
- mrasd_class = vsms.get_masd_class(options.virt)
- mrasd = mrasd_class(name=default_dom, megabytes=32)
-
- params = {
- "vssd" : vssd,
- "rasd" : [drasd.mof(), mrasd.mof()]
- }
-
- create_using_definesystem(default_dom,
- options.ip,
- params=params,
- virt=options.virt)
-
- cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
- rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
-
- status = FAIL
- for rasd in rasds:
- if rasd["Address"] == temp:
- status = check_rasd_size(rasd, test_size)
- break
-
- return status
+ logger.info("Verified %i bytes" % cim_size)
+ return PASS
@do_main(sup_types)
def main():
@@ -113,14 +81,29 @@
return FAIL
logger.info("Created temp disk %s of size %i bytes" % (temp, test_size))
+
+ cxml = get_class(options.virt)(default_dom, mem=32,
+ disk_file_path=temp, disk="hda")
+ try:
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ raise Exception("Failed to define the dom: %s" % default_dom)
- try:
- status = test_rasd(options, temp, test_size)
- except Exception, e:
- logger.error("Failed to test RASD: %s" % e)
+ cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData')
+ rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
- undefine_test_domain(default_dom, options.ip, options.virt)
+ status = FAIL
+ for rasd in rasds:
+ if rasd["Address"] == temp:
+ status = check_rasd_size(rasd, test_size)
+ break
+
+ except Exception, details:
+ logger.error("Failed to test RASD: %s" % details)
+ status = FAIL
+
kill_image(options.ip, temp)
+ cxml.undefine(options.ip)
return status
15 years, 9 months
[PATCH] [TEST] #2 Update VSMS 01_definesystem_name.py to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231345874 28800
# Node ID 02df4284e91f0c3def604cf9e208bf5df256fe91
# Parent c3e4470bce26b1da0e848f5be2ae411b9ea1b937
[TEST] #2 Update VSMS 01_definesystem_name.py to use cim_() functions
Updates:
-Added cim_destroy() to destroy the guest at the end of the test
-Reworded log message for clarity
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r c3e4470bce26 -r 02df4284e91f suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Tue Jan 06 11:56:13 2009 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Wed Jan 07 08:31:14 2009 -0800
@@ -23,12 +23,10 @@
#
import sys
-import pywbem
-from VirtLib import utils
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
from XenKvmLib.const import do_main
from CimTest.Globals import logger
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.vxml import get_class
SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
default_dom = 'test_domain'
@@ -37,10 +35,19 @@
def main():
options = main.options
- status = create_using_definesystem(default_dom, options.ip,
- virt=options.virt)
- undefine_test_domain(default_dom, options.ip,
- virt=options.virt)
+ cxml = get_class(options.virt)(default_dom)
+
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Unable to define %s" % default_dom)
+ return FAIL
+
+ status = cxml.cim_start(options.ip)
+ if status != PASS:
+ logger.info("Failed to start the defined domain: %s" % default_dom)
+
+ cxml.cim_destroy(options.ip)
+ cxml.undefine(options.ip)
return status
15 years, 9 months
[PATCH] TEST] #3 Fixing 41_cs_to_settingdefinestate.py CS tc
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1231407135 28800
# Node ID 4271244c8945d777e6f42afd5cf98c433df05c2e
# Parent 840f4651f746882475188adba781fafbf583c07b
TEST] #3 Fixing 41_cs_to_settingdefinestate.py CS tc.
Changes:
--------
>From Patch 2 to 3:
------------------
1) Removed space between Exception and the (
2) changed destroy to cim_destroy
>From Patch 1 to 2:
------------------
1) Removed ununsed variables.
2) Algined to comments line to 80 columns.
3) removed check_len(), print_err() functions.
4) Made main() and get_SDS_verify_RASD_build_vssdc_input() more modular and small.
Patch 1:
--------
This test has been almost re-written to accomdate latest library changes.
1) cim_define and cim_start usage.
2) Use the library fn enum_rasd().
3) Removed unnecessary import statements.
4) Algined the tc to 80 columns.
Tested for KVM and Xen with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 840f4651f746 -r 4271244c8945 suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Tue Jan 06 11:56:13 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Thu Jan 08 01:32:15 2009 -0800
@@ -27,12 +27,12 @@
# SettingsDefineState.
#
# It traverses the following path:
-# {ComputerSystem} (select the guest domain) --> [SystemDevice](from output select
-# guest domain instances of Device, from the guest domain instances,
-# select one Device instance) --> [SettingsDefineState] (from output, select a RASD
-# instance - should only be 1) --> [VSSDComponent] (from output, select a VSSD instance
-# - should only be 1) --> [SettingsDefineState] (Verify the ComputerSystem instance is
-# the one we started with)
+# {ComputerSystem} (select the guest domain) --> [SystemDevice](from output
+# select guest domain instances of Device, from the guest domain instances,
+# select one Device instance) --> [SettingsDefineState] (from output, select
+# a RASD instance - should only be 1) --> [VSSDComponent] (from output,
+# select a VSSD instance - should only be 1) --> [SettingsDefineState]
+# (Verify the ComputerSystem instance is the one we started with)
#
# Steps:
# ------
@@ -41,367 +41,289 @@
# and and verify the EnabledState is 2.
# 3) Create info list for the guest domain to be used later for comparison.
# 4) Get the various devices allocated to the domain by using the SystemDevice
-# association and giving the ComputerSystem output from the previous enumeration
-# as inputs to the association.
-# 5) For each of the Devices get the association on SettingsDefineState, we should
-# get only one record as output.
+# association and giving the ComputerSystem output from the previous
+# enumeration as inputs to the association.
+# 5) For each of the Devices get the association on SettingsDefineState, we
+# should get only one record as output.
# 6) Verify the Disk, Memory, Network, Processor RASD values.
# 7) Call VSSDComponent association for each of the RASD types, we should
# get only one VSSD record as output.
-# 8) Verify the VSSD output for every VSSDComponent association with the RASD types.
-# 9) Using the VSSD output query the SettingsDefineState association, again we should
-# get only one computersystem record as output.
-# 10)Verify the computersystem values with the computersystem info that was created from
-# the enumeration in the beginning.
+# 8) Verify the VSSD output for every VSSDComponent association with the
+# RASD types.
+# 9) Using the VSSD output query the SettingsDefineState association, again we
+# should get only one computersystem record as output.
+# 10)Verify the computersystem values with the computersystem info that was
+# created from the enumeration in the beginning.
# 11) Destroy the domain.
-# Date : 05.02.2008
+# Date : 05.02.2008
import sys
from VirtLib import utils
from XenKvmLib.vxml import get_class
from XenKvmLib.classes import get_typed_class
-from XenKvmLib.test_doms import destroy_and_undefine_all
-from XenKvmLib.assoc import Associators, AssociatorNames
-from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORNAMES, \
-CIM_ERROR_ASSOCIATORS
+from XenKvmLib.assoc import Associators, AssociatorNames, compare_all_prop
+from CimTest.Globals import logger, CIM_ERROR_ASSOCIATORS
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib import rasd
-from XenKvmLib.rasd import verify_procrasd_values, verify_netrasd_values, \
-verify_diskrasd_values, verify_memrasd_values, rasd_init_list
-from XenKvmLib.common_util import poll_for_state_change
-from XenKvmLib.classes import get_typed_class
+from XenKvmLib.rasd import enum_rasds
+from XenKvmLib.enumclass import GetInstance
+from XenKvmLib.common_util import parse_instance_id
sup_types = ['Xen', 'XenFV', 'KVM']
test_dom = "CrossClass_GuestDom"
-test_vcpus = 1
-test_mem = 128
-test_mac = "00:11:22:33:44:aa"
-def vssd_init_list(virt):
- """
- Creating the lists that will be used for comparisons.
- """
- if virt == 'XenFV':
- virt = 'Xen'
-
- vssd_values = {
- 'Caption' : "Virtual System",
- 'InstanceID' : '%s:%s' % (virt, test_dom),
- 'ElementName' : test_dom,
- 'VirtualSystemIdentifier' : test_dom,
- 'VirtualSystemType' : virt,
- 'Classname' : get_typed_class(virt,
- "VirtualSystemSettingData")
- }
-
- return vssd_values
-
-def cs_init_list(cs_dom):
- """
- Creating the lists that will be used for comparisons.
- """
- cs_values = {
- 'Caption' : cs_dom.Caption,
- 'EnabledState' : cs_dom.EnabledState,
- 'RequestedState' : cs_dom.RequestedState,
- 'CreationClassName' : cs_dom.CreationClassName,
- 'Name' : cs_dom.Name
- }
- return cs_values
-
-def setup_env(server, virt, test_disk):
+def setup_env(server, virt):
vsxml_info = None
- status = PASS
- destroy_and_undefine_all(server)
virt_xml = get_class(virt)
- vsxml_info = virt_xml(test_dom, mem = test_mem,
- vcpus=test_vcpus,
- mac = test_mac,
- disk = test_disk)
+ vsxml_info = virt_xml(test_dom)
+ ret = vsxml_info.cim_define(server)
+ if not ret:
+ logger.error("Failed to define the dom: %s", test_dom)
+ return FAIL, vsxml_info
- ret = vsxml_info.create(server)
+ status = vsxml_info.cim_start(server)
if not ret:
- logger.error("Failed to create the dom: %s", test_dom)
- status = FAIL
+ logger.error("Failed to start the dom: %s", test_dom)
+ vsxml_info.undefine(server)
+ return FAIL, vsxml_info
- return status, vsxml_info
+ return PASS, vsxml_info
-
-def print_err(err, detail, cn):
- logger.error(err % cn)
- logger.error("Exception: %s", detail)
-
-def vssd_sds_err( an, fieldname, ret_val, exp_val):
- error = "Mismatching %s Values in %s association"
- details = "Returned %s instead of %s"
- err = error % (fieldname, an)
- detail = details % (ret_val, exp_val)
- logger.error(err)
- logger.error(detail)
-
-def get_associatornames_info(server, virt, vsxml, cn, an, qcn, name):
- status = PASS
- assoc_info = []
- try:
- assoc_info = AssociatorNames(server,
- an,
- cn,
- CreationClassName=cn,
- Name = name)
- if len(assoc_info) < 1:
- logger.error("%s returned %i %s objects" % (an, len(assoc_info), qcn))
- status = FAIL
- except Exception, detail:
- print_err(CIM_ERROR_ASSOCIATORNAMES, detail, cn)
- status = FAIL
-
- if status != PASS:
- vsxml.destroy(server)
-
- return status, assoc_info
-
-def get_associators_info(server, virt, vsxml, cn, an, qcn, instid):
+def get_associators_info(server, cn, an, qcn, instid):
status = PASS
assoc_info = []
try:
assoc_info = Associators(server,
- an,
- cn,
- InstanceID = instid)
+ an,
+ cn,
+ InstanceID = instid)
if len(assoc_info) < 1:
- logger.error("%s returned %i %s objects" %
- (an, len(assoc_info), qcn))
+ logger.error("%s returned %i %s objects",
+ an, len(assoc_info), qcn)
status = FAIL
except Exception, detail:
- print_err(CIM_ERROR_ASSOCIATORS, detail, cn)
+ logger.error(CIM_ERROR_ASSOCIATORS, cn)
+ logger.error("Exception: %s", detail)
status = FAIL
-
- if status != PASS:
- vsxml.destroy(server)
return status, assoc_info
-def check_len(an, assoc_list_info, qcn, exp_len):
- if len(assoc_list_info) != exp_len:
- logger.error("%s returned %i %s objects", an,
- len(assoc_list_info), qcn)
- return FAIL
- return PASS
+def init_rasd_list(virt, ip):
+ rasd_insts = {}
+ rasds, status = enum_rasds(virt, ip)
+ if status != PASS:
+ logger.error("Enum RASDs failed")
+ return rasd_insts, status
-def get_SDS_verify_RASD_build_vssdc_input(server, virt, vsxml,
- test_disk, sd_assoc_info):
- status = PASS
- in_setting_define_state = {}
- in_vssdc = {}
- prasd = get_typed_class(virt, 'ProcResourceAllocationSettingData')
- mrasd = get_typed_class(virt, 'MemResourceAllocationSettingData')
- nrasd = get_typed_class(virt, 'NetResourceAllocationSettingData')
- drasd = get_typed_class(virt, 'DiskResourceAllocationSettingData')
+ for rasd_cn, rasd_list in rasds.iteritems():
+ for rasd in rasd_list:
+ guest, dev, status = parse_instance_id(rasd.InstanceID)
+ if status != PASS:
+ logger.error("Unable to parse InstanceID: %s" % rasd.InstanceID)
+ return rasd_insts, FAIL
+ if guest == test_dom:
+ rasd_insts[rasd.Classname] = rasd
+
+ return rasd_insts, PASS
+
+
+def verify_values(assoc_info, vssd_cs_values, an, qcn):
+ if len(assoc_info) != 1:
+ logger.error("%s returned %i %s objects, Expected 1", an,
+ len(assoc_info), qcn)
+ return FAIL
+
+ vssd_cs_assoc = assoc_info[0]
+ return compare_all_prop(vssd_cs_assoc, vssd_cs_values)
+
+def build_sd_info(sd_assoc_info, qcn, an, rasd_values):
+ sd_info = {}
+
+ # Building the input for SettingsDefineState association.
+ for sd_val in sd_assoc_info:
+ if sd_val['SystemName'] == test_dom:
+ classname_keyvalue = sd_val['CreationClassName']
+ deviceid = sd_val['DeviceID']
+ sd_info[classname_keyvalue] = deviceid
+
+ # Expect the SystemDevice records == len(rasd_values) entries.
+ if len(sd_info) != len(rasd_values):
+ logger.error("%s returned %i %s objects, Expected %i", an,
+ len(sd_info), qcn, len(rasd_values))
+ return FAIL, sd_info
+
+ return PASS, sd_info
+
+def get_cs_sysdev_info(server, virt, qcn, rasd_val):
+ sd_info={}
+ try:
+ cs_class = get_typed_class(virt, 'ComputerSystem')
+ keys = { 'Name' : test_dom, 'CreationClassName' : cs_class }
+ dom_cs = GetInstance(server, cs_class, keys)
+ if dom_cs.Name != test_dom:
+ raise Exception("Instance matching %s was not returned" % test_dom)
+
+ an = get_typed_class(virt, 'SystemDevice')
+ sd_assoc = AssociatorNames(server, an, cs_class,
+ CreationClassName=cs_class,
+ Name=test_dom)
+ if len(sd_assoc) < 1:
+ raise Exception("%s returned %d %s objects" \
+ % (an, len(sd_assoc), qcn))
+
+ status, sd_info = build_sd_info(sd_assoc, qcn, an, rasd_val)
+ if status != PASS:
+ raise Exception("Failed to get SystemDevice info for: %s" \
+ % test_dom)
+
+ except Exception, details:
+ logger.error("Exception details: %s", details)
+ return FAIL, dom_cs, sd_info
+
+ return PASS, dom_cs, sd_info
+
+def get_sds_info(server, virt, cs_cn, rasd_values,
+ in_setting_define_state, qcn):
+ sds_info = {}
try:
- # Building the input for SettingsDefineState association.
- for i in range(len(sd_assoc_info)):
- if sd_assoc_info[i]['SystemName'] == test_dom:
- classname_keyvalue = sd_assoc_info[i]['CreationClassName']
- deviceid = sd_assoc_info[i]['DeviceID']
- in_setting_define_state[classname_keyvalue] = deviceid
-
- # Expect the SystemDevice to return 4 logical device records.
- # one each for memory, network, disk and processor and hence 4.
- # and hence expect the in_setting_define_state to contain just 4 entries.
- an = get_typed_class(virt, "SystemDevice")
- qcn = "Logical Devices"
- exp_len = 4
- if check_len(an, in_setting_define_state, qcn, exp_len) != PASS:
- return FAIL, in_setting_define_state
-
- # Get the rasd values that will be used to compare with the SettingsDefineState
- # output.
- status, rasd_values, in_list = rasd_init_list(vsxml, virt, test_disk,
- test_dom, test_mac,
- test_mem)
- if status != PASS:
- return status, rasd_values
-
- sccn = get_typed_class(virt,"ComputerSystem")
- an = get_typed_class(virt,"SettingsDefineState")
+ an = get_typed_class(virt,"SettingsDefineState")
for cn, devid in sorted(in_setting_define_state.items()):
- assoc_info = Associators(server,
- an,
- cn,
- DeviceID = devid,
+ assoc_info = Associators(server, an, cn, DeviceID = devid,
CreationClassName = cn,
SystemName = test_dom,
- SystemCreationClassName = sccn)
+ SystemCreationClassName = cs_cn)
- # we expect only one RASD record to be returned for each device that is used to
- # query with the SettingsDefineState association.
+ # we expect only one RASD record to be returned for each device
+ # type when queried with SDS association.
if len(assoc_info) != 1:
- logger.error("%s returned %i %s objects" % (an, len(assoc_info), cn))
- status = FAIL
- break
- index = (len(assoc_info) - 1)
- rasd = rasd_values[cn]
- CCName = assoc_info[index].classname
- if CCName == prasd:
- status = verify_procrasd_values(assoc_info[index], rasd)
- elif CCName == nrasd:
- status = verify_netrasd_values(assoc_info[index], rasd)
- elif CCName == drasd:
- status = verify_diskrasd_values(assoc_info[index], rasd)
- elif CCName == mrasd:
- status = verify_memrasd_values(assoc_info[index], rasd)
- else:
- status = FAIL
+ raise Exception("%s returned %d %s objects, Expected 1" \
+ % (an, len(assoc_info), cn))
+
+ assoc_val = assoc_info[0]
+ CCName = assoc_val.classname
+ exp_rasd = rasd_values[CCName]
+ if assoc_val['InstanceID'] != exp_rasd.InstanceID:
+ raise Exception("Got %s instead of %s" \
+ % (assoc_val['InstanceID'],
+ exp_rasd.InstanceID))
+
+ # Build the input required for VSSDC association query.
+ vs_name = assoc_val['InstanceID']
+ if vs_name.find(test_dom) >= 0:
+ instid = assoc_val['InstanceID']
+ sds_info[CCName] = instid
+
+ if len(sds_info) != len(rasd_values):
+ raise Exception("%s returned %i %s objects, Expected %i" \
+ % (an, len(sds_info), qcn, len(rasd_values)))
+
+ except Exception, details:
+ logger.error("Exception: %s", details)
+ return FAIL, sds_info
+
+ return PASS, sds_info
+
+def get_vssd_info(server, virt, in_vssdc_list, qcn):
+ try:
+ # Get the vssd values which will be used for verifying the
+ # VSSD output from the VSSDC results.
+ if virt == "XenFV":
+ instIdval = "Xen:%s" % test_dom
+ else:
+ instIdval = "%s:%s" % (virt, test_dom)
+
+ vssd_class = get_typed_class(virt, 'VirtualSystemSettingData')
+ keys = { 'InstanceID' : instIdval }
+ vssd_values = GetInstance(server, vssd_class, keys)
+ if vssd_values.ElementName != test_dom:
+ raise Exception("Instance matching %s was not returned" % test_dom)
+
+ an = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
+ for cn, instid in sorted((in_vssdc_list.items())):
+ status, vssd_assoc_info = get_associators_info(server, cn, an,
+ vssd_class,
+ instid)
if status != PASS:
- logger.error("Mistmatching RASD values" )
- break
- vs_name = assoc_info[index]['InstanceID']
- if vs_name.find(test_dom) >= 0:
- instid = assoc_info[index]['InstanceID']
- in_vssdc[CCName] = instid
- except Exception, detail:
- print_err(CIM_ERROR_ASSOCIATORS, detail, an)
- status = FAIL
- return status, in_vssdc
+ raise Exception("Failed to get VSSD info")
+ status = verify_values(vssd_assoc_info, vssd_values, an, qcn)
+ if status != PASS:
+ raise Exception("VSSD values verification error")
-def verify_fields(an, field_name, vssd_cs_assoc_info, vssd_cs_values):
- if vssd_cs_assoc_info[field_name] != vssd_cs_values[field_name]:
- vssd_sds_err(an, field_name, vssd_cs_assoc_info[field_name], \
- vssd_cs_values[field_name])
- return FAIL
- return PASS
+ except Exception, details:
+ logger.error("Exception details: %s", details)
+ return FAIL, vssd_assoc_info
+ return PASS, vssd_assoc_info
-def verify_VSSD_values(assoc_info, vssd_values, an, qcn):
- # We expect that VirtualSystemSettingDataComponent returns only one
- # VirtualSystemSettingData object when queried with disk, processor,
- # network and memory rasd's and all of them return the same output.
- exp_len = 1
+def verify_vssdc_assoc(server, virt, cs_class, vssd_assoc_info, dom_cs):
+ try:
+ # Since the VirtualSystemSettingDataComponent returns similar
+ # output when queried with every RASD, we are taking the output of
+ # the last associtaion query as inputs for
+ # querying SettingsDefineState.
+ cn = vssd_assoc_info[0].classname
+ an = get_typed_class(virt, 'SettingsDefineState')
+ instid = vssd_assoc_info[0]['InstanceID']
+ status, cs_assoc_info = get_associators_info(server, cn, an,
+ cs_class, instid)
+ if status != PASS:
+ raise Exception("Failed to get assoc info for dom: %s", test_dom)
- if check_len(an, assoc_info, qcn, exp_len) != PASS:
+ # verify the results of SettingsDefineState with the cs_values list
+ # that was built using the output of the GetInstance on ComputerSystem.
+ status = verify_values(cs_assoc_info, dom_cs, an, cs_class)
+
+ except Exception, details:
+ logger.error("Exception details: %s", details)
return FAIL
- vssd_assoc = assoc_info[0]
- if verify_fields(an, 'Caption', vssd_assoc, vssd_values) != PASS:
- return FAIL
- if verify_fields(an, 'InstanceID', vssd_assoc, vssd_values) != PASS:
- return FAIL
- if verify_fields(an, 'ElementName', vssd_assoc, vssd_values) != PASS:
- return FAIL
- if verify_fields(an, 'VirtualSystemIdentifier', vssd_assoc, vssd_values) != PASS:
- return FAIL
- if verify_fields(an, 'VirtualSystemType', vssd_assoc, vssd_values) != PASS:
- return FAIL
- if vssd_assoc.classname != vssd_values['Classname']:
- vssd_sds_err(an, 'Classname', vssd_assoc.classname,
- vssd_values['Classname'])
- return FAIL
- return PASS
-def verify_CS_values(assoc_info, cs_values, an, qcn):
- exp_len = 1
-
- if check_len(an, assoc_info, qcn, exp_len) != PASS:
- return FAIL
- cs_assoc = assoc_info[0]
- if verify_fields(an, 'Caption', cs_assoc, cs_values) != PASS:
- return FAIL
- if verify_fields(an, 'EnabledState', cs_assoc, cs_values) != PASS:
- return FAIL
- if verify_fields(an, 'RequestedState', cs_assoc, cs_values) != PASS:
- return FAIL
- if verify_fields(an, 'CreationClassName', cs_assoc, cs_values) != PASS:
- return FAIL
- if verify_fields(an, 'Name', cs_assoc, cs_values) != PASS:
- return FAIL
- return PASS
+ return status
+
@do_main(sup_types)
def main():
server = main.options.ip
virt = main.options.virt
- if virt == 'Xen':
- test_disk = "xvda"
- else:
- test_disk = "hda"
- status, vsxml = setup_env(server, virt, test_disk)
- if status != PASS:
- return status
+ try:
+ status, vsxml = setup_env(server, virt)
+ if status != PASS:
+ return status
- status, cs_dom = poll_for_state_change(server, virt, test_dom, 2,
- timeout=10)
- if status != PASS and cs_dom.RequestedState != 0:
- vsxml.destroy(server)
- return FAIL
+ qcn = 'Logical Devices'
+ rasd_val, status = init_rasd_list(virt, server)
- # Creating the cs info list which will be used later for comparison.
- cs_values = cs_init_list(cs_dom)
-
- cn = cs_dom.CreationClassName
- an = get_typed_class(virt, 'SystemDevice')
- qcn = 'Logical Devices'
- name = test_dom
- status, sd_assoc_info = get_associatornames_info(server, virt, vsxml,
- cn, an, qcn, name)
- if status != PASS or len(sd_assoc_info) == 0:
- return status
+ status, dom_cs, sd_info = get_cs_sysdev_info(server, virt,
+ qcn, rasd_val)
+ if status != PASS:
+ raise Exception("Failed to get SystemDevice information")
- status, in_vssdc_list = get_SDS_verify_RASD_build_vssdc_input(server, virt,
- vsxml, test_disk,
- sd_assoc_info)
- if status != PASS or len(in_vssdc_list) == 0 :
- vsxml.destroy(server)
- return status
+ cs_class = dom_cs.CreationClassName
- # Verifying that the in_vssdc_list contains 4 entries one each for mem rasd,
- # network rasd, processor rasd and disk rasd.
- exp_len = 4
- if check_len(an, in_vssdc_list, qcn, exp_len) != PASS:
- vsxml.destroy(server)
- return FAIL
+ status, sds_info = get_sds_info(server, virt, cs_class, rasd_val,
+ sd_info, qcn)
+ if status != PASS:
+ raise Exception("Failed to get SetingDefineState information")
- # Get the vssd values which will be used for verifying the
- # VirtualSystemSettingData output from the
- # VirtualSystemSettingDataComponent results.
- vssd_values = vssd_init_list(virt)
- an = get_typed_class(virt, 'VirtualSystemSettingDataComponent')
- qcn = get_typed_class(virt, 'VirtualSystemSettingData')
- for cn, instid in sorted((in_vssdc_list.items())):
- status, vssd_assoc_info = get_associators_info(server, virt, vsxml, cn,
- an, qcn, instid)
- if status != PASS or len(vssd_assoc_info) == 0:
- break
- status = verify_VSSD_values(vssd_assoc_info, vssd_values, an, qcn)
+ status, vssd_assoc_info = get_vssd_info(server, virt, sds_info, qcn)
if status != PASS:
- break
- if status != PASS:
- vsxml.destroy(server)
- return status
+ raise Exception("Failed to get VSSD information")
- # Since the VirtualSystemSettingDataComponent returns similar
- # output when queried with every RASD, we are taking the output of
- # the last associtaion query as inputs for
- # querying SettingsDefineState.
- cn = vssd_assoc_info[0].classname
- an = get_typed_class(virt, 'SettingsDefineState')
- qcn = get_typed_class(virt, 'ComputerSystem')
- instid = vssd_assoc_info[0]['InstanceID']
- status, cs_assoc_info = get_associators_info(server, virt, vsxml, cn,
- an, qcn, instid)
- if status != PASS or len(cs_assoc_info) == 0:
- return status
+ status = verify_vssdc_assoc(server, virt, cs_class,
+ vssd_assoc_info, dom_cs)
- # verify the results of SettingsDefineState with the cs_values list that was
- # built using the output of the enumeration on ComputerSystem.
- status = verify_CS_values(cs_assoc_info, cs_values, an, qcn)
- vsxml.destroy(server)
+ except Exception, details:
+ logger.error("Exception details is %s", details)
+ status = FAIL
+
+ vsxml.cim_destroy(server)
+ vsxml.undefine(server)
return status
if __name__ == "__main__":
sys.exit(main())
15 years, 9 months
[PATCH] [TEST] #2 Update CSI 01 to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231347232 28800
# Node ID 39f538ac0d3023d202572ddc47021633c30d9de2
# Parent 02df4284e91f0c3def604cf9e208bf5df256fe91
[TEST] #2 Update CSI 01 to use cim_() functions.
Updates:
-Cleanup import statements
-Remove unnecessary blank lines
-Remove unnecessary call to cim_destroy()
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 02df4284e91f -r 39f538ac0d30 suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
--- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Wed Jan 07 08:31:14 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Wed Jan 07 08:53:52 2009 -0800
@@ -21,26 +21,20 @@
#
import sys
-import os
-import signal
-import time
-from pywbem.cim_obj import CIMInstanceName
+from os import waitpid, kill, fork, _exit, WNOHANG
+from signal import SIGKILL
+from time import sleep
from CimTest.Globals import logger
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib.common_util import create_using_definesystem, \
- call_request_state_change
-from XenKvmLib.test_doms import destroy_and_undefine_domain
from XenKvmLib.classes import get_typed_class
from XenKvmLib.indication_tester import CIMIndicationSubscription
from XenKvmLib.vxml import set_default
-from XenKvmLib.vsms import get_vsms_class
+from XenKvmLib.vxml import get_class
SUPPORTED_TYPES = ['Xen', 'XenFV', 'KVM']
test_dom = "domU"
-REQ_STATE = 2
-TIME = "00000000000000.000000:000"
def sub_ind(ip, virt):
dict = set_default(ip)
@@ -70,28 +64,22 @@
return sub_list, ind_names, dict
-def gen_ind(test_dom, ip, vtype, ind):
+def gen_ind(test_dom, ip, vtype, ind, cxml):
if ind == "define":
- return create_using_definesystem(test_dom, ip, virt=vtype)
-
+ ret = cxml.cim_define(ip)
+ if not ret:
+ return FAIL
+ return PASS
elif ind == "start":
- rc = call_request_state_change(test_dom, ip, REQ_STATE, TIME, vtype)
- if rc != 0:
- logger.error("Failed to start domain: %s" % test_dom)
+ status = cxml.cim_start(ip)
+ if status != PASS:
+ logger.error("Failed to start domain: %s", test_dom)
return FAIL
return PASS
-
elif ind == "destroy":
- service = get_vsms_class(vtype)(ip)
- try:
- classname = get_typed_class(vtype, 'ComputerSystem')
- cs_ref = CIMInstanceName(classname, keybindings = {
- 'Name':test_dom,
- 'CreationClassName':classname})
- service.DestroySystem(AffectedSystem=cs_ref)
- except Exception, details:
- logger.error('Unknow exception happened')
- logger.error(details)
+ ret = cxml.cim_destroy(ip)
+ if not ret:
+ logger.error("Unable to destroy %s", test_dom)
return FAIL
return PASS
@@ -121,7 +109,7 @@
def poll_for_ind(pid, ind_name):
status = FAIL
for i in range(0, 20):
- pw = os.waitpid(pid, os.WNOHANG)
+ pw = waitpid(pid, WNOHANG)
# If pid exits, waitpid returns [pid, return_code]
# If pid is still running, waitpid returns [0, 0]
@@ -134,12 +122,12 @@
elif pw[1] == 0 and i < 19:
if i % 10 == 0:
logger.info("In child, waiting for %s indication", ind_name)
- time.sleep(1)
+ sleep(1)
else:
# Time is up and waitpid never returned the expected pid
if pw[0] != pid:
logger.error("Waited too long for %s indication", ind_name)
- os.kill(pid, signal.SIGKILL)
+ kill(pid, SIGKILL)
else:
logger.error("Received indication error: %d" % pw[1])
@@ -151,34 +139,38 @@
@do_main(SUPPORTED_TYPES)
def main():
options = main.options
+ ip = options.ip
+ virt = options.virt
status = FAIL
- sub_list, ind_names, dict = sub_ind(options.ip, options.virt)
+ sub_list, ind_names, dict = sub_ind(ip, virt)
ind_list = ["define", "start", "destroy"]
+ cxml = get_class(virt)(test_dom)
+
for ind in ind_list:
sub = sub_list[ind]
ind_name = ind_names[ind]
try:
- pid = os.fork()
+ pid = fork()
if pid == 0:
status = handle_request(sub, ind_name, dict, len(ind_list))
if status != PASS:
- os._exit(1)
+ _exit(1)
- os._exit(0)
+ _exit(0)
else:
try:
- status = gen_ind(test_dom, options.ip, options.virt, ind)
+ status = gen_ind(test_dom, ip, virt, ind, cxml)
if status != PASS:
- os.kill(pid, signal.SIGKILL)
+ kill(pid, SIGKILL)
raise Exception("Unable to generate indication")
status = poll_for_ind(pid, ind)
except Exception, details:
- os.kill(pid, signal.SIGKILL)
+ kill(pid, SIGKILL)
raise Exception(details)
except Exception, details:
@@ -190,7 +182,7 @@
sub.unsubscribe(dict['default_auth'])
logger.info("Cancelling subscription for %s" % ind_names[ind])
- destroy_and_undefine_domain(test_dom, options.ip, options.virt)
+ cxml.undefine(ip)
return status
15 years, 9 months