# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1264716059 28800
# Node ID 4bd00149b4a04b6c02efda72e3de45a86c806feb
# Parent b863f339b41bab9569c8306b804377a99bd3b199
[TEST] #2 Verify creation of a guest with a floppy device
Updates:
-Fix typo in header comment
-Change rasd.['InstanceID'].find("Default") to
"Default" is in rasd.['InstanceID']
-Consolidate error conditions into one if statement since the debug message
printed is the same
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r b863f339b41b -r 4bd00149b4a0
suites/libvirt-cim/cimtest/VirtualSystemManagementService/25_definesystem_floppy.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/25_definesystem_floppy.py Thu
Jan 28 14:00:59 2010 -0800
@@ -0,0 +1,149 @@
+#!/usr/bin/python
+#
+# Copyright 2010 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
+#
+# Purpose:
+# Verify providers support floppy devices
+#
+# Steps:
+# 1) Create a guest with a regular disk device and a floppy device
+# 2) Build RASD parameters, making sure to specify floppy device
+# 3) Verify guest is defined properly
+#
+
+import sys
+from CimTest.Globals import logger
+from CimTest.ReturnCodes import FAIL, PASS, SKIP
+from XenKvmLib.classes import get_typed_class, inst_to_mof
+from XenKvmLib.rasd import get_rasd_templates
+from XenKvmLib.const import do_main, get_provider_version, \
+ KVM_secondary_disk_path, default_pool_name
+from XenKvmLib.vxml import get_class
+from XenKvmLib.vsms import VIRT_DISK_TYPE_FLOPPY
+from XenKvmLib.common_util import parse_instance_id
+from XenKvmLib.enumclass import EnumInstances
+
+sup_types = ['Xen', 'XenFV', 'KVM']
+test_dom = 'rstest_floppy'
+
+floppy_rev = 1023
+
+def get_rasd_list(ip, virt, addr):
+ drasd_cn = get_typed_class(virt, "DiskResourceAllocationSettingData")
+ pool_id = "DiskPool/%s" % default_pool_name
+
+ rasds = get_rasd_templates(ip, virt, pool_id)
+ if len(rasds) < 1:
+ logger.info("No RASD templates returned for %s", pool_id)
+ return []
+
+ rasd_list = {}
+
+ for rasd in rasds:
+ if rasd.classname != drasd_cn:
+ continue
+
+ if rasd['EmulatedType'] == VIRT_DISK_TYPE_FLOPPY and \
+ "Default" in rasd['InstanceID']:
+
+ rasd['Address'] = addr
+ rasd_list[rasd.classname] = inst_to_mof(rasd)
+
+ return rasd_list
+
+def verify_floppy_disk(ip, virt, addr, guest_name):
+ inst = None
+
+ try:
+ drasd_cn = get_typed_class(virt, 'DiskResourceAllocationSettingData')
+ enum_list = EnumInstances(ip, drasd_cn)
+
+ if enum_list < 1:
+ raise Exception("No %s instances returned" % drasd_cn)
+
+ for rasd in enum_list:
+ guest, dev, status = parse_instance_id(rasd.InstanceID)
+ if status != PASS:
+ raise Exception("Unable to parse InstanceID: %s" % \
+ rasd.InstanceID)
+
+ if guest == guest_name:
+ inst = rasd
+ break
+
+ if inst is None or inst.Address != addr:
+ raise Exception("%s instance for %s not found" % (drasd_cn,
+ guest_name))
+
+ if inst.EmulatedType != VIRT_DISK_TYPE_FLOPPY:
+ raise Exception("Expected device to be of %d type" % \
+ (VIRT_DISK_TYPE_FLOPPY))
+
+ except Exception, details:
+ logger.error(details)
+ return FAIL
+
+ return PASS
+
+@do_main(sup_types)
+def main():
+ options = main.options
+
+ status = FAIL
+
+ curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
+ if curr_cim_rev < floppy_rev:
+ logger.error("Floppy support is available in rev >= %s",
floppy_rev)
+ return SKIP
+
+ cxml = get_class(options.virt)(test_dom)
+
+ addr = KVM_secondary_disk_path
+
+ guest_defined = False
+
+ try:
+ rasd_list = get_rasd_list(options.ip, options.virt, addr)
+ if len(rasd_list) < 1:
+ raise Exception("Unable to get template RASDs for %s" % test_dom)
+
+ cxml.set_res_settings(rasd_list)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ raise Exception("Unable to define %s" % test_dom)
+
+ guest_defined = True
+
+ status = verify_floppy_disk(options.ip, options.virt, addr, test_dom)
+ if status != PASS:
+ raise Exception("Failed to verify disk path for %s" % test_dom)
+
+ except Exception, details:
+ logger.error(details)
+ status = FAIL
+
+ if guest_defined == True:
+ cxml.undefine(options.ip)
+
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
+
diff -r b863f339b41b -r 4bd00149b4a0 suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri Dec 11 16:12:01 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Thu Jan 28 14:00:59 2010 -0800
@@ -37,6 +37,10 @@
RASD_TYPE_INPUT = 13
RASD_TYPE_STOREVOL = 32768
+VIRT_DISK_TYPE_DISK = 0
+VIRT_DISK_TYPE_CDROM = 1
+VIRT_DISK_TYPE_FLOPPY = 2
+
VSSD_RECOVERY_NONE = 2
VSSD_RECOVERY_RESTART = 3
VSSD_RECOVERY_PRESERVE = 123