# HG changeset patch
# User Deepti B.Kalakeri <deeptik(a)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(a)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(a)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())
+