[PATCH] [TEST] Print info messages instead of errors in check_guest_state()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231351800 28800
# Node ID 64672f2644fb26a6788f171685269e59b9029142
# Parent f0ebc2def018b3d34a897762e249e922ca44f71f
[TEST] Print info messages instead of errors in check_guest_state()
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r f0ebc2def018 -r 64672f2644fb suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jan 07 09:51:15 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jan 07 10:10:00 2009 -0800
@@ -547,8 +547,7 @@
(cs.RequestedState, req_state))
except Exception, detail:
- logger.error("Unable to check guest state")
- logger.error("Exception: %s" % detail)
+ logger.info("Exception: %s" % detail)
return FAIL
return PASS
15 years, 11 months
[PATCH] [TEST] #2 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 1231320603 28800
# Node ID 484cffb372f419a676209b368b60fc538d544c73
# Parent 64b84ef28b22d17dd22027c632a9dc44d642d2b5
[TEST] #2 Fixing 41_cs_to_settingdefinestate.py CS tc.
Changes:
--------
>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 64b84ef28b22 -r 484cffb372f4 suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Tue Dec 30 00:58:06 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Wed Jan 07 01:30:03 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)
+ except Exception, details:
+ logger.error("Exception details is %s", details)
+ status = FAIL
+
vsxml.destroy(server)
+ vsxml.undefine(server)
return status
if __name__ == "__main__":
sys.exit(main())
15 years, 11 months
[PATCH] #2 Added 2 end points for the ServiceAffectsElement association, both related to the LogicalDevice class
by Richard Maciel
# HG changeset patch
# User Richard Maciel <richardm(a)br.ibm.com>
# Date 1229729923 7200
# Node ID ebb3a754af1f3eed21b8daf65c0b72ad9d7e65e3
# Parent c4b178c78475fe8ad11328d80f38bcdcf0d50e70
#2 Added 2 end points for the ServiceAffectsElement association, both related to the LogicalDevice class.
- ConsoleRedirectionService <-> DisplayController
- ConsoleRedirectionService <-> PointingDevice
Signed-off-by: Richard Maciel <richardm(a)br.ibm.com>
diff -r c4b178c78475 -r ebb3a754af1f src/Makefile.am
--- a/src/Makefile.am Fri Dec 19 21:10:32 2008 -0200
+++ b/src/Makefile.am Fri Dec 19 21:38:43 2008 -0200
@@ -213,9 +213,9 @@
libVirt_ConsoleRedirectionServiceCapabilities_la_SOURCES = Virt_ConsoleRedirectionServiceCapabilities.c
-libVirt_ServiceAffectsElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_ConsoleRedirectionService.la
+libVirt_ServiceAffectsElement_la_DEPENDENCIES = libVirt_ComputerSystem.la libVirt_Device.la libVirt_ConsoleRedirectionService.la
libVirt_ServiceAffectsElement_la_SOURCES = Virt_ServiceAffectsElement.c
-libVirt_ServiceAffectsElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_ConsoleRedirectionService
+libVirt_ServiceAffectsElement_la_LIBADD = -lVirt_ComputerSystem -lVirt_Device -lVirt_ConsoleRedirectionService
libVirt_KVMRedirectionSAP_la_SOURCES = Virt_KVMRedirectionSAP.c
diff -r c4b178c78475 -r ebb3a754af1f src/Virt_ServiceAffectsElement.c
--- a/src/Virt_ServiceAffectsElement.c Fri Dec 19 21:10:32 2008 -0200
+++ b/src/Virt_ServiceAffectsElement.c Fri Dec 19 21:38:43 2008 -0200
@@ -29,9 +29,11 @@
#include <libcmpiutil/libcmpiutil.h>
#include <libcmpiutil/std_association.h>
#include "misc_util.h"
+#include "svpc_types.h"
#include "Virt_ComputerSystem.h"
#include "Virt_ConsoleRedirectionService.h"
+#include "Virt_Device.h"
const static CMPIBroker *_BROKER;
@@ -41,15 +43,70 @@
{
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *instance = NULL;
-
+ const char *host = NULL;
+ int i;
+ int num_of_domains;
+
if (!match_hypervisor_prefix(ref, info))
- return s;
+ goto out;
s = get_console_rs(ref, &instance, _BROKER, info->context, true);
if (s.rc != CMPI_RC_OK)
- return s;
+ goto out;
s = enum_domains(_BROKER, ref, list);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ num_of_domains = list->cur;
+
+ /*
+ * For each domain, insert its video and pointer devices into
+ * the list
+ */
+ for (i = 0; i < num_of_domains; i++) {
+ s.rc = cu_get_str_prop(list->list[i], "Name", &host);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = enum_devices(_BROKER,
+ ref,
+ host,
+ CIM_RES_TYPE_INPUT,
+ list);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = enum_devices(_BROKER,
+ ref,
+ host,
+ CIM_RES_TYPE_GRAPHICS,
+ list);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
+ out:
+ return s;
+}
+
+static CMPIStatus validate_cs_or_dev_ref(const CMPIContext *context,
+ const CMPIObjectPath *ref)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ char* classname;
+
+ classname = class_base_name(CLASSNAME(ref));
+
+ if (STREQC(classname, "ComputerSystem")) {
+ s = get_domain_by_ref(_BROKER, ref, &inst);
+ } else if ((STREQC(classname, "PointingDevice")) ||
+ (STREQC(classname, "DisplayController"))) {
+ s = get_device_by_ref(_BROKER, ref, &inst);
+ }
+
+ free(classname);
return s;
}
@@ -63,8 +120,8 @@
if (!match_hypervisor_prefix(ref, info))
return s;
-
- s = get_domain_by_ref(_BROKER, ref, &inst);
+
+ s = validate_cs_or_dev_ref(info->context, ref);
if (s.rc != CMPI_RC_OK)
return s;
@@ -83,6 +140,12 @@
"Xen_ComputerSystem",
"KVM_ComputerSystem",
"LXC_ComputerSystem",
+ "Xen_PointingDevice",
+ "KVM_PointingDevice",
+ "LXC_PointingDevice",
+ "Xen_DisplayController",
+ "KVM_DisplayController",
+ "LXC_DisplayController",
NULL
};
15 years, 11 months
[PATCH] [TEST] Update CSI 01 to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231271658 28800
# Node ID d0b13b624d8c54bb8c625f3d0855ac7f80cdcdbd
# Parent 270c97141e74456e051361572b2ba77af8f0fd94
[TEST] Update CSI 01 to use cim_() functions.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 270c97141e74 -r d0b13b624d8c suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py
--- a/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jan 06 11:09:46 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystemIndication/01_created_indication.py Tue Jan 06 11:54:18 2009 -0800
@@ -24,23 +24,17 @@
import os
import signal
import time
-from pywbem.cim_obj import CIMInstanceName
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,24 @@
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
@@ -151,12 +141,16 @@
@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]
@@ -171,7 +165,7 @@
os._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)
raise Exception("Unable to generate indication")
@@ -190,7 +184,8 @@
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.cim_destroy(ip)
+ cxml.undefine(ip)
return status
15 years, 11 months
[PATCH] [TEST] 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 1231268986 28800
# Node ID 270c97141e74456e051361572b2ba77af8f0fd94
# Parent d40521f17a98e3403eef62b0e5c42d8b3b8f5c09
[TEST] Update VSMS 01_definesystem_name.py to use cim_() functions
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r d40521f17a98 -r 270c97141e74 suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Tue Jan 06 10:15:08 2009 -0800
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Tue Jan 06 11:09:46 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,18 @@
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("Starting defined %s failed" % default_dom)
+
+ cxml.undefine(options.ip)
return status
15 years, 11 months
[PATCH] [TEST] #2 Update Memory - 02_defgetmem.py to use cim_define()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231265708 28800
# Node ID d40521f17a98e3403eef62b0e5c42d8b3b8f5c09
# Parent cb00f1c2beec9467129888d13bf9976b30e93c0a
[TEST] #2 Update Memory - 02_defgetmem.py to use cim_define()
Also, modify the test to use PASS/FAIL values.
Updates:
-Fixed some typos
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r cb00f1c2beec -r d40521f17a98 suites/libvirt-cim/cimtest/Memory/02_defgetmem.py
--- a/suites/libvirt-cim/cimtest/Memory/02_defgetmem.py Mon Jan 05 15:02:59 2009 -0800
+++ b/suites/libvirt-cim/cimtest/Memory/02_defgetmem.py Tue Jan 06 10:15:08 2009 -0800
@@ -29,64 +29,57 @@
# 4. Verify the DeviceId and domName with the instance info.
import sys
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
+from CimTest.ReturnCodes import PASS, FAIL
from XenKvmLib.devices import get_dom_mem_inst
from CimTest.Globals import logger
from XenKvmLib.const import do_main
+from XenKvmLib.vxml import get_class
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
default_dom = "domu"
def check_mem(memInst):
- status = 0
for mem in memInst:
if mem['SystemName'] != default_dom:
- logger.error("Inst returned is for guesst %s, expected guest %s.",
+ logger.error("Inst returned is for guest %s, expected guest %s.",
mem['SystemName'], default_dom)
- return 1
+ return FAIL
devid = "%s/%s" % (default_dom, "mem" )
if mem['DeviceID'] != devid:
logger.error("DeviceID %s does not match expected %s.",
mem['DeviceID'], devid)
- status = 1
- else:
- logger.info("Memory : Verified domain %s having DeviceID %s" % \
- (default_dom, devid))
+ return FAIL
- return status
+ logger.info("Verified domain %s having DeviceID %s", default_dom, devid)
+
+ return PASS
@do_main(sup_types)
def main():
options = main.options
- status = 0
+ status = FAIL
- undefine_test_domain(default_dom, options.ip)
-
-
+ cxml = get_class(options.virt)(default_dom)
try:
- rc = create_using_definesystem(default_dom, options.ip, params=None,
- ref_config='', exp_err=None,
- virt=options.virt)
- if rc != 0:
- raise Exception("Unable to create domain %s using DefineSys()" % default_dom)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ raise Exception("Failed to define the guest: %s" % default_dom)
memInst = get_dom_mem_inst(options.virt, options.ip, default_dom)
+ if len(memInst) == 0:
+ raise Exception("Failed to get mem instances for %s" % default_dom)
- if len(memInst) == 0:
- raise Exception("Failied to retrieve mem instances for %s" % default_dom)
-
- rc = check_mem(memInst)
- if rc != 0:
- raise Exception("Memory instance for %s is not as expected." % default_dom)
+ status = check_mem(memInst)
+ if status != PASS:
+ raise Exception("Memory inst for %s not as expected." % default_dom)
except Exception, detail:
logger.error("Exception: %s" % detail)
- status = 1
+ status = FAIL
- undefine_test_domain(default_dom, options.ip)
+ cxml.undefine(options.ip)
return status
15 years, 11 months
[PATCH] [TEST] #2 Update Processor -t 02_definesys_get_procs.py to use cim_define()
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231196579 28800
# Node ID cb00f1c2beec9467129888d13bf9976b30e93c0a
# Parent 8e6a23215bdf94810add8264555ab43ff2ec210b
[TEST] #2 Update Processor -t 02_definesys_get_procs.py to use cim_define()
Updates:
-Fixed some silly typos
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 8e6a23215bdf -r cb00f1c2beec suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py
--- a/suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py Tue Jan 06 10:10:23 2009 -0800
+++ b/suites/libvirt-cim/cimtest/Processor/02_definesys_get_procs.py Mon Jan 05 15:02:59 2009 -0800
@@ -32,11 +32,7 @@
#
import sys
-import pywbem
-from XenKvmLib.classes import get_typed_class
-from XenKvmLib.vxml import XenXML, KVMXML, get_class
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import create_using_definesystem
+from XenKvmLib.vxml import get_class
from XenKvmLib.devices import get_dom_proc_insts
from CimTest.Globals import logger
from XenKvmLib.const import do_main
@@ -55,7 +51,7 @@
for proc in procs:
if proc['SystemName'] != default_dom:
- logger.error("Inst returned is for guesst %s, expected guest %s.",
+ logger.error("Inst returned is for guest %s, expected guest %s.",
procs['SystemName'], default_dom)
return FAIL
@@ -71,33 +67,29 @@
@do_main(sup_types)
def main():
options = main.options
- status = PASS
-
- undefine_test_domain(default_dom, options.ip)
+ status = FAIL
try:
- rc = create_using_definesystem(default_dom, options.ip, params=None,
- ref_config=' ', exp_err=None,
- virt=options.virt)
- if rc != 0:
- raise Exception("Unable create domain %s using DefineSystem()" \
- % default_dom)
+ cxml = get_class(options.virt)(default_dom)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ raise Exception("Failed to define the guest: %s" % default_dom)
proc_list = get_dom_proc_insts(options.virt, options.ip, default_dom)
if len(proc_list) == 0:
- raise Exception("Failied to retrieve vcpu instances for %s" \
+ raise Exception("Failed to retrieve vcpu instances for %s" \
% default_dom)
- rc = check_processors(proc_list)
- if rc != 0:
+ status = check_processors(proc_list)
+ if status != PASS:
raise Exception("Processor instances for %s are not as expected." \
% default_dom)
-
+
except Exception, detail:
logger.error("Exception: %s" % detail)
status = FAIL
- undefine_test_domain(default_dom, options.ip)
+ cxml.undefine(options.ip)
return status
15 years, 11 months
[PATCH] [TEST] #2 Rename 27_define_suspend_errs.py to 27_define_pause_errs.py
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231193318 28800
# Node ID 95141f9f1593e01a70ba5c64444a4a33d0bb4854
# Parent 5ca146678acf60551b90b1e07a94633f0668b8c3
[TEST] #2 Rename 27_define_suspend_errs.py to 27_define_pause_errs.py
CIM requested state 9 is pause, not suspend. So this test is being renamed.
It was also updated to use cim_() functions.
Updates:
-Change "suspended" in comments and log message to "paused"
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 5ca146678acf -r 95141f9f1593 suites/libvirt-cim/cimtest/ComputerSystem/27_define_pause_errs.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/27_define_pause_errs.py Mon Jan 05 14:08:38 2009 -0800
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Anoop V Chakkalakkal<anoop.vijayan(a)in.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
+#
+# Test Case Info:
+# --------------
+# This test case is used to verify the Virtual System State Transition
+# The test is considered to be successful if the request for the invalid
+# state change from defined to paused fails
+#
+# Date: 05-03-2008
+#
+
+import sys
+from CimTest.Globals import logger
+from XenKvmLib.const import do_main
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.vxml import get_class
+
+sup_types = ['Xen', 'XenFV', 'LXC', 'KVM']
+
+default_dom = 'test_domain'
+
+@do_main(sup_types)
+def main():
+ options = main.options
+ server = options.ip
+ virt = options.virt
+ status = FAIL
+
+ try:
+ # define the vs
+ cxml = get_class(options.virt)(default_dom)
+ ret = cxml.cim_define(server)
+ if not ret:
+ raise Exception("Failed to define the guest: %s" % default_dom)
+
+ status = cxml.cim_pause(server)
+ if status != PASS:
+ raise Exception("Unable pause dom '%s'" % default_dom)
+
+ except Exception, details:
+ logger.error("Exception: %s", details)
+ status = FAIL
+
+ if status != FAIL:
+ logger.error("Expected Defined -> Paused state transition to fail")
+ status = FAIL
+ else:
+ status = PASS
+
+ cxml.undefine(server)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
diff -r 5ca146678acf -r 95141f9f1593 suites/libvirt-cim/cimtest/ComputerSystem/27_define_suspend_errs.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/27_define_suspend_errs.py Mon Jan 05 13:41:14 2009 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright 2008 IBM Corp.
-#
-# Authors:
-# Anoop V Chakkalakkal<anoop.vijayan(a)in.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
-#
-# Test Case Info:
-# --------------
-# This test case is used to verify the Virtual System State Transition
-# The test is considered to be successful if the request for the invalid
-# state change from defined to suspend fails
-#
-# List of Valid state values (Refer to VSP spec doc Table 2 for more)
-# ---------------------------------
-# State | Values
-# ---------------------------------
-# Defined | 3
-# Suspend | 9
-#
-# Date: 05-03-2008
-#
-
-import sys
-import pywbem
-from VirtLib import utils
-from CimTest.Globals import logger
-from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
-from XenKvmLib.test_doms import destroy_and_undefine_domain
-from XenKvmLib.common_util import try_request_state_change, \
- create_using_definesystem
-
-sup_types = ['Xen', 'XenFV', 'LXC', 'KVM']
-
-SUSPEND_STATE = 9
-default_dom = 'test_domain'
-TIME = "00000000000000.000000:000"
-exp_rc = pywbem.CIM_ERR_FAILED
-exp_desc = 'Domain not running'
-
-
-@do_main(sup_types)
-def main():
- options = main.options
- server = options.ip
- virt = options.virt
- status = FAIL
-
- try:
- # define the vs
- status = create_using_definesystem(default_dom, server, virt=virt)
- if status != PASS:
- logger.error("Unable to define domain '%s' using DefineSystem()",
- default_dom)
- return status
-
- except Exception, details:
- logger.error("Exception: %s", details)
- destroy_and_undefine_domain(default_dom, server, virt)
- return FAIL
-
- status = try_request_state_change(default_dom, server,
- SUSPEND_STATE, TIME, exp_rc,
- exp_desc, virt)
-
- if status != PASS:
- logger.error("Expected Defined -> Suspended state transition to fail")
-
- destroy_and_undefine_domain(default_dom, server, virt)
- return status
-
-if __name__ == "__main__":
- sys.exit(main())
15 years, 11 months
[PATCH] [TEST] #2 Update 32_start_reboot.py to use cim_() functions
by Kaitlin Rupert
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231264630 28800
# Node ID d0566805a9ec7b5d3a9a20af71b89053b3b01b09
# Parent ae40dfa1b8f6e134d200233d2e5b3395855cafa2
[TEST] #2 Update 32_start_reboot.py to use cim_() functions
Also change cim_state_change() to support enable and requested state parameters.
Updates:
-Remove unused variables
-Don't return an XFAIL is starting the guest fails
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ae40dfa1b8f6 -r d0566805a9ec 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 Tue Jan 06 09:57:10 2009 -0800
@@ -28,34 +28,18 @@
# 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']
bug_libvirt = "00005"
-ACTIVE_STATE = 2
-REBOOT_STATE = 10
default_dom = 'cs_test_domain'
-TIME = "00000000000000.000000:000"
@do_main(sup_types)
def main():
@@ -64,45 +48,34 @@
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
+ 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 d0566805a9ec 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 Tue Jan 06 09:57:10 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, 11 months