[Libvirt-cim] [PATCH] [TEST] Adding KVM and XenFV support to 41_cs_to_settingdefinestate.py
Deepti B Kalakeri
deeptik at linux.vnet.ibm.com
Mon Aug 11 12:52:39 UTC 2008
Deepti B. Kalakeri wrote:
> # HG changeset patch
> # User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
> # Date 1218440570 25200
> # Node ID 0b5dea4e96cd0e128c0da6019cc545964deeba49
> # Parent 8ac224c6840c79e73c54b7c59647f5be5117d29e
> [TEST] Adding KVM and XenFV support to 41_cs_to_settingdefinestate.py.
>
> 1) Added support for XenFV, KVM.
> 2) Removed get_inst_from_list().
> 3) Used poll_for_state_change to get the CS instance and also verify the enabled state is set to 2
> 4) Also verifying that the RequestedState is set to 0 when the VS is created.
>
> Tested with Xen, XenFV and KVM on latest sources.
>
> Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
>
> diff -r 8ac224c6840c -r 0b5dea4e96cd suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Thu Aug 07 23:45:42 2008 -0700
> +++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Mon Aug 11 00:42:50 2008 -0700
> @@ -37,9 +37,9 @@
> # Steps:
> # ------
> # 1) Create a guest domain.
> -# 2) Enumerate ComputerSystem.
> -# 3) Select the guest domain from the output and create info list for the guest domain
> -# to be used later for comparison.
> +# 2) Enumerate ComputerSystem and Select the guest domain from the output
> +# 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.
> @@ -70,26 +70,31 @@ from XenKvmLib import rasd
> 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
>
> -sup_types = ['Xen']
> +sup_types = ['Xen', 'XenFV', 'KVM']
>
> test_dom = "CrossClass_GuestDom"
> test_vcpus = 1
> test_mem = 128
> test_mac = "00:11:22:33:44:aa"
> -test_disk = "xvda"
>
> 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' : "Xen_VirtualSystemSettingData"
> + '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
> @@ -99,19 +104,20 @@ 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, \
> + '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):
> +def setup_env(server, virt, test_disk):
> 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,
> @@ -137,23 +143,7 @@ def vssd_sds_err( an, fieldname, ret_val
> logger.error(err)
> logger.error(detail)
>
> -def get_inst_from_list(server, vsxml, cn, cs_list, exp_val):
> - status = PASS
> - ret = -1
> - inst = None
> - for inst in cs_list:
> - if inst.Name == exp_val:
> - ret = PASS
> - break
> -
> - if ret != PASS:
> - logger.error("%s with %s was not returned" % (cn, exp_val))
> - vsxml.destroy(server)
> - status = FAIL
> -
> - return status, inst
> -
> -def get_associatornames_info(server, vsxml, cn, an, qcn, name):
> +def get_associatornames_info(server, virt, vsxml, cn, an, qcn, name):
> status = PASS
> assoc_info = []
> try:
> @@ -161,7 +151,8 @@ def get_associatornames_info(server, vsx
> an,
> cn,
> CreationClassName=cn,
> - Name = name)
> + Name = name,
> + virt=virt)
> if len(assoc_info) < 1:
> logger.error("%s returned %i %s objects" % (an, len(assoc_info), qcn))
> status = FAIL
> @@ -174,14 +165,15 @@ def get_associatornames_info(server, vsx
>
> return status, assoc_info
>
> -def get_associators_info(server, vsxml, cn, an, qcn, instid):
> +def get_associators_info(server, virt, vsxml, cn, an, qcn, instid):
> status = PASS
> assoc_info = []
> try:
> assoc_info = Associators(server,
> an,
> cn,
> - InstanceID = instid)
> + InstanceID = instid,
> + virt=virt)
> if len(assoc_info) < 1:
> logger.error("%s returned %i %s objects" %
> (an, len(assoc_info), qcn))
> @@ -208,31 +200,39 @@ def get_SDS_verify_RASD_build_vssdc_inpu
> 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')
> +
> try:
> -# Building the input for Xen_SettingsDefineState association.
> +
> + # Building the input for Xen_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 Xen_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 = "Xen_SystemDevice"
> +
> + # Expect the Xen_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 Xen_SettingsDefineState
> -# output.
> +
> + # Get the rasd values that will be used to compare with the Xen_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
> -
> - sccn = "Xen_ComputerSystem"
> - an = "Xen_SettingsDefineState"
> + return status, rasd_values
> +
> + sccn = get_typed_class(virt,"ComputerSystem")
> + an = get_typed_class(virt,"SettingsDefineState")
> for cn, devid in sorted(in_setting_define_state.items()):
> assoc_info = Associators(server,
> an,
> @@ -240,10 +240,11 @@ def get_SDS_verify_RASD_build_vssdc_inpu
> DeviceID = devid,
> CreationClassName = cn,
> SystemName = test_dom,
> - SystemCreationClassName = sccn)
> + SystemCreationClassName = sccn,
> + virt=virt)
>
> -# we expect only one RASD record to be returned for each device that is used to
> -# query with the Xen_SettingsDefineState association.
> + # we expect only one RASD record to be returned for each device that is used to
> + # query with the Xen_SettingsDefineState association.
> if len(assoc_info) != 1:
> logger.error("%s returned %i %s objects" % (an, len(assoc_info), cn))
> status = FAIL
> @@ -251,13 +252,13 @@ def get_SDS_verify_RASD_build_vssdc_inpu
> index = (len(assoc_info) - 1)
> rasd = rasd_values[cn]
> CCName = assoc_info[index].classname
> - if CCName == 'Xen_ProcResourceAllocationSettingData':
> + if CCName == prasd:
> status = verify_procrasd_values(assoc_info[index], rasd)
> - elif CCName == 'Xen_NetResourceAllocationSettingData':
> + elif CCName == nrasd:
> status = verify_netrasd_values(assoc_info[index], rasd)
> - elif CCName == 'Xen_DiskResourceAllocationSettingData':
> + elif CCName == drasd:
> status = verify_diskrasd_values(assoc_info[index], rasd)
> - elif CCName == 'Xen_MemResourceAllocationSettingData':
> + elif CCName == mrasd:
> status = verify_memrasd_values(assoc_info[index], rasd)
> else:
> status = FAIL
>
I wanted to reduce the above functions like the way done in
logicaldevices.py library function.
Since the change to the rasd.py library function required rework on
quite a few other test case I plan to do it later.
Thanks and Regards,
Deepti.
> @@ -283,9 +284,9 @@ def verify_fields(an, field_name, vssd_c
>
>
> def verify_VSSD_values(assoc_info, vssd_values, an, qcn):
> -# We expect that Xen_VirtualSystemSettingDataComponent returns only one
> -# Xen_VirtualSystemSettingData object when queried with disk, processor,
> -# network and memory rasd's and all of them return the same output.
> + # We expect that Xen_VirtualSystemSettingDataComponent returns only one
> + # Xen_VirtualSystemSettingData object when queried with disk, processor,
> + # network and memory rasd's and all of them return the same output.
> exp_len = 1
> if check_len(an, assoc_info, qcn, exp_len) != PASS:
> return FAIL
> @@ -301,8 +302,8 @@ def verify_VSSD_values(assoc_info, vssd_
> 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'])
> + vssd_sds_err(an, 'Classname', vssd_assoc.classname,
> + vssd_values['Classname'])
> return FAIL
> return PASS
>
> @@ -327,60 +328,56 @@ def main():
> def main():
> server = main.options.ip
> virt = main.options.virt
> - status, vsxml = setup_env(server, virt)
> + if virt == 'Xen':
> + test_disk = "xvda"
> + else:
> + test_disk = "hda"
> +
> + status, vsxml = setup_env(server, virt, test_disk)
> if status != PASS:
> return status
>
> - cs_enum = computersystem.enumerate(server)
> - if len(cs_enum) == 0:
> + 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 status
> - cn = cs_enum[0].CreationClassName
> - status, cs_dom = get_inst_from_list(server,
> - vsxml,
> - cn,
> - cs_enum,
> - test_dom)
> - if status != PASS:
> - vsxml.destroy(server)
> - return status
> + return FAIL
>
> -# Creating the cs info list which will be used later for comparison.
> + # Creating the cs info list which will be used later for comparison.
> cs_values = cs_init_list(cs_dom)
> - if cs_values['EnabledState'] != 2 :
> - logger.error("Improper EnabledState value set for domain %s", test_dom)
> - logger.error("Should have been 2 instead of %s", cs_values['EnabledState'])
> - vsxml.destroy(server)
> - return FAIL
>
> cn = cs_dom.CreationClassName
> - an = 'Xen_SystemDevice'
> + an = get_typed_class(virt, 'SystemDevice')
> qcn = 'Logical Devices'
> name = test_dom
> - status, sd_assoc_info = get_associatornames_info(server, vsxml,
> + 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, 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
> -# Verifying that the in_vssdc_list contains 4 entries one each for mem rasd,
> -# network rasd, processor rasd and disk rasd.
> +
> + # 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
> -# Get the vssd values which will be used for verifying the Xen_VirtualSystemSettingData
> -# output from the Xen_VirtualSystemSettingDataComponent results.
> +
> + # Get the vssd values which will be used for verifying the
> + # Xen_VirtualSystemSettingData output from the
> + # Xen_VirtualSystemSettingDataComponent results.
> vssd_values = vssd_init_list(virt)
> - an = 'Xen_VirtualSystemSettingDataComponent'
> - qcn = 'Xen_VirtualSystemSettingData'
> + 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, vsxml, cn, an, qcn,
> - instid)
> + 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)
> @@ -389,18 +386,22 @@ def main():
> if status != PASS:
> vsxml.destroy(server)
> return status
> -# Since the Xen_VirtualSystemSettingDataComponent returns similar output when queried with
> -# every RASD, we are taking the output of the last associtaion query as inputs for
> -# querying Xen_SettingsDefineState.
> +
> + # Since the Xen_VirtualSystemSettingDataComponent returns similar
> + # output when queried with every RASD, we are taking the output of
> + # the last associtaion query as inputs for
> + # querying Xen_SettingsDefineState.
> cn = vssd_assoc_info[0].classname
> - an = 'Xen_SettingsDefineState'
> - qcn = 'Xen_ComputerSystem'
> + 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, vsxml, cn, an, qcn, instid)
> + 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
> -# verify the results of Xen_SettingsDefineState with the cs_values list that was
> -# built using the output of the enumeration on Xen_ComputerSystem.
> +
> + # verify the results of Xen_SettingsDefineState with the cs_values list that was
> + # built using the output of the enumeration on Xen_ComputerSystem.
> status = verify_CS_values(cs_assoc_info, cs_values, an, qcn)
> vsxml.destroy(server)
> return status
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>
More information about the Libvirt-cim
mailing list