[PATCH 0 of 2] [TEST] #2 Add new tc to verify the VNC password field of the Domain.

# HG changeset patch # User Deepti B.Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1248080978 25200 # Node ID d8ce1c1e439da8f1f26bc65e1c192ba5d590445b # Parent 14b666e2a803048c1ce4e71b550a49c62915b3a3 [TEST] #2 Add new tc to verify the VNC password field of the Domain. Patch2 : --------- Moved the destroy and undefine after the exception Verified with KVM and current sources on F10 and SLES11. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 14b666e2a803 -r d8ce1c1e439d suites/libvirt-cim/cimtest/VirtualSystemManagementService/20_verify_vnc_password.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/20_verify_vnc_password.py Mon Jul 20 02:09:38 2009 -0700 @@ -0,0 +1,107 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri <deeptik@linux.vnet.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 testcase verifies VNC password can be specified via GRASD +# for the guest and the same is set in the Password field of GRASD. +# +# Date: 16-07-2009 +# + +import sys +from XenKvmLib import vxml +from CimTest.Globals import logger +from XenKvmLib.enumclass import EnumInstances +from CimTest.ReturnCodes import FAIL, PASS, SKIP +from XenKvmLib.const import do_main, get_provider_version +from XenKvmLib.classes import get_typed_class + +libvirtcim_vnc_passwd_changes=925 + +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] +default_dom = 'vncpasswd_domain' +passwd = 'cimtest123' + +def verify_grasd_passwd_value(virt, server): + rasd_list = [] + classname = get_typed_class(virt, "GraphicsResourceAllocationSettingData") + try: + rasd_list = EnumInstances(server, classname, ret_cim_inst=True) + if len(rasd_list) < 1: + logger.error("%s returned %i instances, excepted at least 1.", + classname, len(rasd_list)) + return FAIL + + inst_id = "%s/graphics" % default_dom + for rasd in rasd_list: + # Verify the Password for the domain is set + if rasd['InstanceID'] == inst_id: + if rasd['Password'] != "" and "*" in rasd['Password']: + logger.info("Password for '%s' is set.", default_dom) + return PASS + + except Exception, detail: + logger.error("Exception: %s", detail) + return FAIL + + logger.error("Password for '%s' is not set.", default_dom) + return FAIL + + +@do_main(sup_types) +def main(): + options = main.options + virt = options.virt + server = options.ip + + curr_cim_rev, changeset = get_provider_version(virt, server) + if curr_cim_rev < libvirtcim_vnc_passwd_changes: + logger.info("VNC Password support not available, feature available in"\ + " '%s' revision..", libvirtcim_vnc_passwd_changes) + return SKIP + + cxml = vxml.get_class(virt)(default_dom, vnc_passwd=passwd) + + try: + ret = cxml.cim_define(server) + if not ret: + raise Exception("Failed to define the dom: %s" % default_dom) + + ret = cxml.cim_start(server) + if ret != PASS: + cxml.undefine(server) + raise Exception("Failed to start the dom: %s" % default_dom) + + status = verify_grasd_passwd_value(virt, server) + if status != PASS: + logger.error("Failed to verify the Password field for domain '%s'", + default_dom) + + except Exception, details: + logger.error(details) + status = FAIL + + cxml.cim_destroy(server) + cxml.undefine(server) + return status + +if __name__ == "__main__": + sys.exit(main()) +

# HG changeset patch # User Deepti B.Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1248081035 25200 # Node ID 7a453b4c7749159ee7e740dc7b8e0e6c69790ad0 # Parent d8ce1c1e439da8f1f26bc65e1c192ba5d590445b [TEST] Modify vsms.py and vxml.py to include vnc_passwd filed for GRASD. Tested with KVM and current sources on F10 and SLES. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r d8ce1c1e439d -r 7a453b4c7749 suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 20 02:09:38 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Mon Jul 20 02:10:35 2009 -0700 @@ -243,7 +243,7 @@ class CIM_GraphicsResourceAllocationSettingData(CIMClassMOF): def __init__(self, name, res_sub_type="vnc", ip="127.0.0.1", - lport='-1', keymap="en-us"): + lport='-1', keymap="en-us", vnc_passwd=None): self.InstanceID = '%s/graphics' %name self.ResourceType = RASD_TYPE_GRAPHICS @@ -255,6 +255,9 @@ if keymap != None: self.KeyMap = keymap + + if vnc_passwd != None: + self.Password = vnc_passwd class Xen_GraphicsResourceAllocationSettingData(CIM_GraphicsResourceAllocationSettingData): diff -r d8ce1c1e439d -r 7a453b4c7749 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jul 20 02:09:38 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jul 20 02:10:35 2009 -0700 @@ -558,7 +558,7 @@ def __init__(self, virt, dom_name, disk_dev, disk_source, net_type, net_name, net_mac, vcpus, mem, mem_allocunits, emu_type, grstype, ip, - port_num, kmap, irstype, btype): + port_num, kmap, irstype, btype, vnc_passwd): self.virt = virt self.domain_name = dom_name self.err_rc = None @@ -581,7 +581,8 @@ name=dom_name) self.gasd = vsms.get_gasd_class(virt)(name=dom_name, res_sub_type=grstype, ip=ip, - lport=port_num, keymap=kmap) + lport=port_num, keymap=kmap, + vnc_passwd=vnc_passwd) self.iasd = vsms.get_iasd_class(virt)(name=dom_name, res_sub_type=irstype, bus_type=btype) @@ -796,7 +797,7 @@ net_name=const.default_network_name, emu_type=None, grstype="vnc", address="127.0.0.1", port_num='-1', keymap="en-us", irstype="mouse", - btype="xen"): + btype="xen", vnc_passwd=None): if not (os.path.exists(const.Xen_kernel_path) \ and os.path.exists(const.Xen_init_path)): logger.error('ERROR: Either the kernel image ' @@ -809,7 +810,7 @@ VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path, ntype, net_name, mac, vcpus, mem, mem_allocunits, emu_type, grstype, address, port_num, keymap, irstype, - btype) + btype, vnc_passwd) def _os(self, os_kernel, os_initrd): os = self.get_node('/domain/os') @@ -861,7 +862,7 @@ net_name=const.default_network_name, emu_type=None, grstype="vnc", address="127.0.0.1", port_num='-1', keymap="en-us", irstype="mouse", - btype="ps2"): + btype="ps2", vnc_passwd=None): if not os.path.exists(disk_file_path): logger.error('Error: Disk image does not exist') sys.exit(1) @@ -869,7 +870,7 @@ VirtCIM.__init__(self, 'KVM', test_dom, disk, disk_file_path, ntype, net_name, mac, vcpus, mem, mem_allocunits, emu_type, grstype, address, - port_num, keymap, irstype, btype) + port_num, keymap, irstype, btype, vnc_passwd) self._os() self._devices(const.KVM_default_emulator, ntype, disk_file_path, disk, mac, net_name) @@ -916,7 +917,7 @@ net_name=const.default_network_name, emu_type=None, grstype="vnc", address="127.0.0.1", port_num='-1', keymap="en-us", - irstype="mouse", btype="ps2"): + irstype="mouse", btype="ps2", vnc_passwd=None): if not os.path.exists(disk_file_path): logger.error('Error: Disk image does not exist') sys.exit(1) @@ -924,7 +925,7 @@ VirtCIM.__init__(self, 'XenFV', test_dom, disk, disk_file_path, ntype, net_name, mac, vcpus, mem, mem_allocunits, emu_type, grstype, address, port_num, keymap, - irstype, btype) + irstype, btype, vnc_passwd) self._features() self._os(const.XenFV_default_loader) self._devices(const.XenFV_default_emulator, @@ -973,12 +974,12 @@ net_name=const.default_network_name, tty=const.LXC_default_tty, grstype="vnc", address="127.0.0.1", port_num='-1', keymap="en-us", - irstype="mouse", btype="usb"): + irstype="mouse", btype="usb", vnc_passwd=None): VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus) VirtCIM.__init__(self, 'LXC', test_dom, const.LXC_default_mp, const.LXC_default_source, ntype, net_name, mac, vcpus, mem, const.default_mallocunits, None, grstype, - address, port_num, keymap, irstype, btype) + address, port_num, keymap, irstype, btype, vnc_passwd) self._os(const.LXC_init_path) self._devices(mac, ntype, net_name, const.LXC_default_tty) self.create_lxc_file(CIM_IP, const.LXC_init_path)
participants (1)
-
Deepti B. Kalakeri