[PATCH] [TEST] Adding new tc to verify KVMRedirectionSAP

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1232018404 28800 # Node ID cc74023eeaf78970482e0a7a0c4c37a7ff997530 # Parent 43bf01b82ce9f627af1b5db55922b0584cd0e3b4 [TEST] Adding new tc to verify KVMRedirectionSAP. Tested with KVM/Xen on current sources and KVM with F9 rpm. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 43bf01b82ce9 -r cc74023eeaf7 suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py Thu Jan 15 03:20:04 2009 -0800 @@ -0,0 +1,166 @@ +#!/usr/bin/python +# +# Copyright 2008 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri <dkalaker@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 +# +# This test case is used to verify the KVMRedirectionSAP properties in detail. +# This test case verifies the following: +# +# When the domain is defined: +# KVMRedirectionSAP.Enabled = 3 and +# KVMRedirectionSAP.[ElementName, Name] = -1:-1 +# +# When the defined domain is started: +# KVMRedirectionSAP.Enabled = 6 and +# KVMRedirectionSAP.[ElementName, Name] = port used in the xml:0 +# +# Date : 15-01-2009 +# + +import sys +from XenKvmLib.vxml import get_class +from XenKvmLib.classes import get_typed_class +from XenKvmLib.const import do_main, get_provider_version +from XenKvmLib.enumclass import EnumInstances +from CimTest.Globals import logger, CIM_ERROR_ENUMERATE +from CimTest.ReturnCodes import PASS, FAIL, SKIP +from XenKvmLib.const import KVMRedSAP_proto, CIM_SAP_AVAILABLE_STATE, \ + CIM_SAP_INACTIVE_STATE + +sup_types = ['Xen', 'KVM'] +libvirtcim_redSAP_changes = 716 +test_dom = 'test_redsap_dom' + +def enum_redsap(server, virt, classname): + redsap_insts = { } + status = FAIL + + try: + redsap_list = EnumInstances(server, classname) + for redsap in redsap_list: + guest = redsap.SystemName + if guest == test_dom: + if redsap.Classname not in redsap_insts.keys(): + redsap_insts[redsap.Classname] = redsap + status = PASS + else: + raise Exception("Got more than one record for: %s" \ + % test_dom) + except Exception, details: + logger.error(CIM_ERROR_ENUMERATE, classname) + logger.error("Exception details: %s", details) + return status, redsap_insts + + +def verify_redsap_values(val_list, redsap_inst, classname): + try: + for key in val_list.keys(): + redsap = redsap_inst[classname] + ret_val = eval('redsap.' + key) + if ret_val != val_list[key]: + raise Exception("'%s' Value Mismatch, Expected %s, Got %s" \ + % (key, val_list[key], ret_val)) + except Exception, details: + logger.error("Exception details: %s", details) + return FAIL + + return PASS + +@do_main(sup_types) +def main(): + virt = main.options.virt + server = main.options.ip + + cname = 'KVMRedirectionSAP' + classname = get_typed_class(virt, cname) + + # This check is required for libivirt-cim providers which do not have + # REDSAP changes in it and the REDSAP provider is available with + # revision >= 716. + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev < libvirtcim_redSAP_changes: + logger.info("'%s' provider not supported, hence skipping the tc ....", + classname) + return SKIP + + vsxml = None + action_start = False + + try: + virt_xml = get_class(virt) + vsxml = virt_xml(test_dom) + ret = vsxml.cim_define(server) + if not ret: + raise Exception("Failed to define the dom: %s" % test_dom) + + status, redsap_inst = enum_redsap(server, virt, classname) + if status != PASS: + raise Exception("Failed to get information on the defined dom:%s" \ + % test_dom) + + # val_list that will be used for comparing with enum of + # KVMRedirectionSAP values + sccn = get_typed_class(virt, 'ComputerSystem') + g_type = vsxml.xml_get_graphics_type() + val_list = { + 'SystemCreationClassName' : sccn, + 'SystemName' : test_dom, + 'CreationClassName' : classname, + 'KVMProtocol' : KVMRedSAP_proto[g_type], + 'EnabledState' : CIM_SAP_INACTIVE_STATE + } + val_list['ElementName'] = val_list['Name'] = "%s:%s" % ('-1', '-1') + + status = verify_redsap_values(val_list, redsap_inst, classname) + if status != PASS: + raise Exception("Failed to verify information on the defined "\ + "dom:%s" % test_dom) + + status = vsxml.cim_start(server) + if not ret: + raise Exception("Failed to start the dom: %s" % test_dom) + + status, redsap_inst = enum_redsap(server, virt, classname) + if status != PASS: + action_start = True + raise Exception("Failed to get information for running dom:%s" \ + % test_dom) + + lport = vsxml.xml_get_graphics_port() + val_list['ElementName'] = val_list['Name'] = "%s:%s" % (lport, '0') + val_list['EnabledState'] = CIM_SAP_AVAILABLE_STATE + + status = verify_redsap_values(val_list, redsap_inst, classname) + if status != PASS: + action_start = True + raise Exception("Failed to verify information for running dom:%s" \ + % test_dom) + + except Exception, detail: + logger.error("Exception: %s", detail) + status = FAIL + + if action_start == True: + vsxml.cim_destroy(server) + + vsxml.undefine(server) + return status + +if __name__ == "__main__": + sys.exit(main()) diff -r 43bf01b82ce9 -r cc74023eeaf7 suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Mon Jan 12 08:22:47 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Thu Jan 15 03:20:04 2009 -0800 @@ -46,6 +46,15 @@ # Default TimeoutPeriod param for CS.RequestedStateChange() TIME = "00000000000000.000000:000" + +#KVMRedirectionSAP protocol values +KVMRedSAP_proto = { 'raw' : 2, 'rdp' : 3, 'vnc' : 4 } + +# CIM values for KVMRedirectionSAP.EnabledState +CIM_SAP_ACTIVE_STATE = 2 +CIM_SAP_INACTIVE_STATE = 3 +CIM_SAP_AVAILABLE_STATE = 6 + # vxml.NetXML default_bridge_name = 'testbridge' diff -r 43bf01b82ce9 -r cc74023eeaf7 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 12 08:22:47 2009 -0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Thu Jan 15 03:20:04 2009 -0800 @@ -413,6 +413,15 @@ '/domain/devices/interface/source/@network') return networkStr + def xml_get_graphics_type(self): + graphicstypeStr = self.get_value_xpath( + '/domain/devices/graphics/@type') + return graphicstypeStr + + def xml_get_graphics_port(self): + graphicsportStr = self.get_value_xpath( + '/domain/devices/graphics/@port') + return graphicsportStr def dumpxml(self, ip): cmd = 'virsh -c %s dumpxml %s' % (self.vuri, self.dname)

Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1232018404 28800 # Node ID cc74023eeaf78970482e0a7a0c4c37a7ff997530 # Parent 43bf01b82ce9f627af1b5db55922b0584cd0e3b4 [TEST] Adding new tc to verify KVMRedirectionSAP.
Tested with KVM/Xen on current sources and KVM with F9 rpm.
I should have caught this earlier, but we're currently doing the following: self.add_sub_node(devices, 'graphics', type='vnc', port='5900', keymap='en-us') This adds the graphics device node to the XML, which is good - we need this when calling define() (i.e. using virsh). However, when cim_define() is called, the XML isn't used at all. Instead, cim_define() passes RASD objects to the DefineSystem() call. Right now, cim_define() doesn't specify a graphics RASD. When the DefineSystem() call is made, the provider is using default values since no graphics RASD is supplied. If you have an existing guest that has a VNC port of 5900, this test will fail.
diff -r 43bf01b82ce9 -r cc74023eeaf7 suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py Thu Jan 15 03:20:04 2009 -0800 @@ -0,0 +1,166 @@
+ g_type = vsxml.xml_get_graphics_type()
This call is getting the graphics value from the XML. However, that might not be an accurate representation of what was passed to the DefineSystem() call. We need to do some cleanup here to ensure that the XML is a reflection of the actual guest that was defined.
+ + lport = vsxml.xml_get_graphics_port()
Same comment here. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Deepti B. Kalakeri wrote:
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1232018404 28800 # Node ID cc74023eeaf78970482e0a7a0c4c37a7ff997530 # Parent 43bf01b82ce9f627af1b5db55922b0584cd0e3b4 [TEST] Adding new tc to verify KVMRedirectionSAP.
Tested with KVM/Xen on current sources and KVM with F9 rpm.
I should have caught this earlier, but we're currently doing the following:
self.add_sub_node(devices, 'graphics', type='vnc', port='5900', keymap='en-us')
This adds the graphics device node to the XML, which is good - we need this when calling define() (i.e. using virsh).
However, when cim_define() is called, the XML isn't used at all. Instead, cim_define() passes RASD objects to the DefineSystem() call. Right now, cim_define() doesn't specify a graphics RASD. When the DefineSystem() call is made, the provider is using default values since no graphics RASD is supplied.
If you have an existing guest that has a VNC port of 5900, this test will fail. Ya, I too overlooked this .
diff -r 43bf01b82ce9 -r cc74023eeaf7 suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/KVMRedirectionSAP/01_enum_KVMredSAP.py Thu Jan 15 03:20:04 2009 -0800 @@ -0,0 +1,166 @@
+ g_type = vsxml.xml_get_graphics_type()
This call is getting the graphics value from the XML. However, that might not be an accurate representation of what was passed to the DefineSystem() call.
We need to do some cleanup here to ensure that the XML is a reflection of the actual guest that was defined.
+ + lport = vsxml.xml_get_graphics_port()
Same comment here.
I will look into this and make the changes to vxml.py on top your changes which are part of "#2 Update VSMS 04_definesystem_ers.py to use cim_define()" -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com

I will look into this and make the changes to vxml.py on top your changes which are part of "#2 Update VSMS 04_definesystem_ers.py to use cim_define()"
Great, this sounds good. I just resubmitted that test. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Deepti B Kalakeri
-
Deepti B. Kalakeri
-
Kaitlin Rupert