libvirt-cim-bounces(a)redhat.com wrote on 2008-10-11 04:30:14:
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1223669037 25200
# Node ID caea4cf97fcb3b095761496bc8d76502fd0039af
# Parent 3e4bbcff3c709620d9d86860b417be4a9b563842
[TEST] Add VSMS 15_mod_system_settings.py
This test verifies the ModifySystemSettings() call.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 3e4bbcff3c70 -r caea4cf97fcb suites/libvirt-
cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-
cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
Fri Oct 10 13:03:57 2008 -0700
@@ -0,0 +1,133 @@
+#!/usr/bin/python
+#
+# Copyright 2008 IBM Corp.
+#
+# Authors:
+# Kaitlin Rupert <karupert(a)us.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
+#
+
+import sys
+import pywbem
+from XenKvmLib import vsms
+from XenKvmLib import vxml
+from CimTest.Globals import logger
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.const import do_main, default_network_name
+from XenKvmLib.classes import get_typed_class, inst_to_mof
+from XenKvmLib.enumclass import GetInstance
+from XenKvmLib.common_util import poll_for_state_change
+
+sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
+default_dom = 'rstest_domain'
+cpu = 2
+RECOVERY_VAL = 3
+DEFINED_STATE = 3
+
+def cleanup_env(ip, virt, cxml):
+ cxml.cim_destroy(ip)
+ cxml.undefine(ip)
Can you remove 'virt' parameter here? It isn't used in
cleanup_env() function. I'm not sure if you have any plans on it.
Thanks!
+
+def get_vssd(ip, virt, get_cim_inst):
+ cn = get_typed_class(virt, "VirtualSystemSettingData")
+ inst = None
+
+ try:
+ if virt == "XenFV":
+ virt = "Xen"
+
+ key_list = {"InstanceID" : "%s:%s" % (virt, default_dom) }
+ inst = GetInstance(ip, cn, key_list, get_cim_inst)
+
+ except Exception, details:
+ logger.error(details)
+ return FAIL, inst
+
+ if inst is None:
+ return FAIL, inst
+
+ return PASS, inst
+
+@do_main(sup_types)
+def main():
+ options = main.options
+
+ test_cases = ["define", "start"]
+ cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
+ service = vsms.get_vsms_class(options.virt)(options.ip)
+
+ for case in test_cases:
+ #Each time through, define guest using a default XML
+ cxml.undefine(options.ip)
+ cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Failed to define the dom: %s", default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ if case == "start":
+ ret = cxml.start(options.ip)
+ if not ret:
+ logger.error("Failed to start %s", default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ status, inst = get_vssd(options.ip, options.virt, True)
+ if status != PASS:
+ logger.error("Failed to get the VSSD instance for %s",
default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ inst['AutomaticRecoveryAction'] = pywbem.cim_types.
Uint16(RECOVERY_VAL)
+ vssd = inst_to_mof(inst)
+
+ ret = service.ModifySystemSettings(SystemSettings=vssd)
+ if ret[0] != 0:
+ logger.error("Failed to modify dom: %s", default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ if case == "start":
+ #This should be replaced with a RSC to shutdownt he guest
+ cxml.destroy(options.ip)
+ status, cs = poll_for_state_change(options.ip,
options.virt,
+ default_dom,
DEFINED_STATE)
+ if status != PASS:
+ logger.error("Failed to destroy %s", default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ status, inst = get_vssd(options.ip, options.virt, False)
+ if status != PASS:
+ logger.error("Failed to get the VSSD instance for %s",
default_dom)
+ cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ if inst.AutomaticRecoveryAction != RECOVERY_VAL:
+ logger.error("%s not updated properly.", default_dom)
+ logger.error("Exp AutomaticRecoveryAction=%d, got %d",
RECOVERY_VAL,
+ inst.AutomaticRecoveryAction)
+ #cleanup_env(options.ip, options.virt, cxml)
+ return FAIL
+
+ cleanup_env(options.ip, options.virt, cxml)
+
+ return PASS
+
+if __name__ == "__main__":
+ sys.exit(main())
+
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim