# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1212424933 25200
# Node ID 76b7fc25cf2ed76481c002c8d3fef1e2e4c6effa
# Parent af001ec333a331b7ac10895ebcadaff9383303f3
[TEST] Add vsms_util.py
This module is for vsms related utility functions (for AddResource, ModifyResource, etc).
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r af001ec333a3 -r 76b7fc25cf2e suites/libvirt-cim/lib/XenKvmLib/vsms_util.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms_util.py Mon Jun 02 09:42:13 2008 -0700
@@ -0,0 +1,96 @@
+#!/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 pywbem
+from CimTest import Globals
+from CimTest.ReturnCodes import FAIL, PASS
+from CimTest.Globals import logger
+
+def add_disk_res(server, service, cxml, vssd_ref, dasd, nddev):
+ try:
+ service.AddResourceSettings(AffectedConfiguration=vssd_ref,
+ ResourceSettings=[str(dasd)])
+ cxml.dumpxml(server)
+ disk_dev = cxml.get_value_xpath(
+ '/domain/devices/disk/target/@dev[. = "%s"]' %
nddev)
+ if disk_dev != nddev:
+ raise Exception('Error adding rs for disk_dev')
+ logger.info('good status for disk_dev')
+ except Exception, details:
+ logger.error('Error invoking AddRS')
+ logger.error(details)
+ return FAIL
+
+ return PASS
+
+def add_net_res(server, service, cxml, vssd_ref, nasd, nnmac):
+ try:
+ service.AddResourceSettings(AffectedConfiguration=vssd_ref,
+ ResourceSettings=[str(nasd)])
+ cxml.dumpxml(server)
+ net_mac = cxml.get_value_xpath(
+ '/domain/devices/interface/mac/@address[. = "%s"]'
% nnmac)
+ if net_mac.lower() != nnmac:
+ raise Exception('Error adding rs for net_mac')
+ logger.info('good status for net_mac')
+ except Exception, details:
+ logger.error('Error invoking AddRS')
+ logger.error(details)
+ return FAIL
+
+ return PASS
+
+def add_proc_res(server, service, cxml, vssd_ref, pasd, npvcpu):
+ try:
+ service.AddResourceSettings(AffectedConfiguration=vssd_ref,
+ ResourceSettings=[str(pasd)])
+ cxml.dumpxml(server)
+ proc_vcpu = cxml.xml_get_vcpu()
+ if int(proc_vcpu) != int(npvcpu):
+ raise Exception('Error adding rs for proc_vcpu')
+ logger.info('good status for proc_vcpu')
+ status = PASS
+ except Exception, details:
+ logger.error('Error invoking AddRS')
+ logger.error(details)
+ return FAIL
+
+ return PASS
+
+def add_mem_res(server, service, cxml, vssd_ref, masd, nmem):
+ try:
+ service.AddResourceSettings(AffectedConfiguration=vssd_ref,
+ ResourceSettings=[str(masd)])
+ cxml.dumpxml(server)
+ mem = cxml.xml_get_mem()
+ if int(mem)/1024 != int(nmem):
+ raise Exception('Error adding rs for mem')
+ logger.info('good status for mem')
+ status = PASS
+ except Exception, details:
+ logger.error('Error invoking AddRS')
+ logger.error(details)
+ return FAIL
+
+ return PASS
+
+