[PATCH] [TEST] #2 Fixing 01_forward.py tc of SystemDevice
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225792617 28800
# Node ID 3ce5cf8fb12feb015f5ecce5c72517c7836b407c
# Parent d1614c101c281b57bd2bc98dfb6625f790748e54
[TEST] #2 Fixing 01_forward.py tc of SystemDevice.
The test needs to be updated with cim_define().
Tested on KVM, LXC and Xen with current sources and F9 rpm.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r d1614c101c28 -r 3ce5cf8fb12f suites/libvirt-cim/cimtest/SystemDevice/01_forward.py
--- a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Tue Nov 04 01:56:57 2008 -0800
@@ -8,6 +8,7 @@
# Kaitlin Rupert <karupert(a)us.ibm.com>
# Veerendra Chandrappa <vechandr(a)in.ibm.com>
# Zhengang Li <lizg(a)cn.ibm.com>
+# 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
@@ -25,10 +26,10 @@
#
import sys
+from sets import Set
from VirtLib import utils
from XenKvmLib import assoc
from XenKvmLib import vxml
-from XenKvmLib import devices
from XenKvmLib.classes import get_typed_class
from CimTest.Globals import logger
from XenKvmLib.const import do_main
@@ -38,72 +39,99 @@
test_dom = "test_domain"
test_mac = "00:11:22:33:44:55"
-test_cpu = 1
+test_cpu = 3
@do_main(sup_types)
def main():
- options= main.options
-
- if options.virt == 'Xen':
+ options = main.options
+ server = options.ip
+ virt = options.virt
+
+ if virt == 'Xen':
test_disk = 'xvdb'
else:
test_disk = 'hdb'
status = PASS
- virt_xml = vxml.get_class(options.virt)
- if options.virt == 'LXC':
- cxml = virt_xml(test_dom)
+ virt_xml = vxml.get_class(virt)
+ if virt == 'LXC':
+ cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac)
else:
- cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, disk = test_disk)
- ret = cxml.create(options.ip)
+ cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac,
+ disk = test_disk)
+
+ ret = cxml.create(server)
if not ret:
logger.error('Unable to create domain %s' % test_dom)
return FAIL
- sd_classname = get_typed_class(options.virt, 'SystemDevice')
- cs_classname = get_typed_class(options.virt, 'ComputerSystem')
+ sd_classname = get_typed_class(virt, 'SystemDevice')
+ cs_classname = get_typed_class(virt, 'ComputerSystem')
- devs = assoc.AssociatorNames(options.ip, sd_classname, cs_classname,
+ devs = assoc.AssociatorNames(server, sd_classname, cs_classname,
Name=test_dom, CreationClassName=cs_classname)
if devs == None:
- logger.error("System association failed")
- return FAIL
- elif len(devs) == 0:
- logger.error("No devices returned")
+ logger.error("'%s' association failed", sd_classname)
+ cxml.destroy(server)
return FAIL
- cn_devid = {
- get_typed_class(options.virt, "NetworkPort") : '%s/%s' % (test_dom, test_mac),
- get_typed_class(options.virt, "Memory") : '%s/mem' % test_dom,
- get_typed_class(options.virt, "LogicalDisk") : '%s/%s' % (test_dom, test_disk),
- get_typed_class(options.virt, "Processor") : '%s/%s' % (test_dom, test_cpu-1)
- }
+ if len(devs) == 0:
+ logger.error("No devices returned")
+ cxml.destroy(server)
+ return FAIL
- key_list = {'DeviceID' : '',
- 'CreationClassName' : '',
- 'SystemName' : test_dom,
- 'SystemCreationClassname' : cs_classname
- }
-
- for dev_cn in cn_devid.keys():
- for dev in devs:
- key_list['CreationClassName'] = dev['CreationClassname']
- key_list['DeviceID'] = dev['DeviceID']
- device = devices.device_of(options.ip, key_list)
- if device.CreationClassName != dev_cn:
- continue
- devid = device.DeviceID
+ mem_cn = get_typed_class(virt, "Memory")
+ exp_pllist = { mem_cn : ['%s/mem' % test_dom] }
+ proc_cn = get_typed_class(virt, "Processor")
+ exp_pllist[proc_cn] = []
+ for i in range(test_cpu):
+ exp_pllist[proc_cn].append( '%s/%s' % (test_dom, i))
- _devid = cn_devid[dev_cn]
- if devid != _devid:
- logger.error("DeviceID `%s` != `%s'" % (devid, _devid))
- status = FAIL
+ if virt != 'LXC':
+ net_cn = get_typed_class(virt, "NetworkPort")
+ disk_cn = get_typed_class(virt, "LogicalDisk")
+ exp_pllist[net_cn] = ['%s/%s' % (test_dom, test_mac)]
+ exp_pllist[disk_cn] = [ '%s/%s' % (test_dom, test_disk)]
+
+ try:
+ res_pllist = {}
+ for items in devs:
+ # The dict has some elements
+ if len(res_pllist) != 0:
+ # If the dict already has the key we append the new value
+ if items.classname in res_pllist.keys():
+ list = []
+ list = res_pllist[items.classname]
+ list.append(items['DeviceID'])
+ res_pllist[items.classname] = list
+ else:
+ # If the dict is not empty, but does not yet contain
+ # items.classname, we create new item
+ res_pllist[items.classname] = [items['DeviceID']]
else:
- logger.info("Examined %s" % _devid)
-
- cxml.destroy(options.ip)
- cxml.undefine(options.ip)
+ # When the dict is empty
+ res_pllist[items.classname] = [items['DeviceID']]
+ #Verifying we get all the expected device class info
+ if Set(exp_pllist.keys()) != Set(res_pllist.keys()):
+ logger.error("Device Class mismatch")
+ raise Exception("Expected Device class list: %s \n \t Got: %s"
+ % (sorted(exp_pllist.keys()),
+ sorted(res_pllist.keys())))
+
+ #Verifying that we get only the expected deviceid
+ #for every device class
+ for key in exp_pllist.keys():
+ if Set(exp_pllist[key]) != Set(res_pllist[key]):
+ logger.error("DeviceID mismatch")
+ raise Exception("Expected DeviceID: %s \n \t Got: %s"
+ % (sorted(exp_pllist[key]),
+ sorted(res_pllist[key])))
+ except Exception, details:
+ logger.error("Exception %s", details)
+ status = FAIL
+
+ cxml.destroy(server)
return status
if __name__ == "__main__":
16 years, 1 month
[PATCH 0 of 5] Fix up associations to SBLIM host system
by Dan Smith
This patch set attempts to patch up our associations for the case where the
SBLIM providers are installed and we use them for our HostSystem class. Since
that class exists in root/cimv2, we have to register our associations there
as well, and make sure they provide paths back to the rest of our providers.
The convert_sblim_hostsystem() function that I use to do this is a bit of a
hack, given that it requires knowledge of how the reference we're passing to
all of our factory functions is used. However, I think it's definitely the
easiest thing to do right now.
Comments are welcome as usual :)
16 years, 1 month
[PATCH] [TEST] Updating 01_enum_crs.py tc of RedirectionService to work with libvirt-cim provider with no CRS support
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225804941 28800
# Node ID 914e2bbfeb62295a2a0afb976ed5b2a72e38daed
# Parent 8118a0e17d219b6886b34176423c45c855f08576
[TEST] Updating 01_enum_crs.py tc of RedirectionService to work with libvirt-cim provider with no CRS support.
Updating 01_enum_crs.py tc of RedirectionService to skip the tc which if CRS provider is not present
in the libvirt_cim provider when the libvirt_cim_revision < 688.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 8118a0e17d21 -r 914e2bbfeb62 suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py
--- a/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Tue Nov 04 05:22:21 2008 -0800
@@ -32,19 +32,28 @@
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.classes import get_typed_class
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.ReturnCodes import PASS, FAIL, SKIP
from XenKvmLib.common_util import get_host_info
from XenKvmLib.const import get_provider_version
SHAREMODE = 3
REDIRECTION_SER_TYPE = 3
CRS_MAX_SAP_REV = 724
+libvirtcim_hr_crs_changes = 688
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
@do_main(sup_types)
def main():
virt = main.options.virt
server = main.options.ip
+
+ # This check is required for libivirt-cim providers which do not have
+ # CRS changes in it and the CRS provider is available with revision >= 688.
+ curr_cim_rev, changeset = get_provider_version(virt, server)
+ if curr_cim_rev < libvirtcim_hr_crs_changes:
+ logger.info("ConsoleRedirectionService provider not supported, "
+ "hence skipping the tc ....")
+ return SKIP
status, host_name, host_cn = get_host_info(server, virt)
if status != PASS:
16 years, 1 month
[PATCH] [TEST] Updating 01_enum_crs.py tc of RedirectionService to work with libvirt-cim provider with no CRS support
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225802905 28800
# Node ID a63c661d0e709149d874d7632ac16f721aea60e6
# Parent d7c8a05587743fd0fafb2d4d53a62896f45d1b31
[TEST] Updating 01_enum_crs.py tc of RedirectionService to work with libvirt-cim provider with no CRS support.
Updating 01_enum_crs.py tc of RedirectionService to skip the tc which if CRS provider is not present
in the libvirt_cim provider when the libvirt_cim_revision < 695.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r d7c8a0558774 -r a63c661d0e70 suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py
--- a/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Tue Nov 04 04:05:05 2008 -0800
+++ b/suites/libvirt-cim/cimtest/RedirectionService/01_enum_crs.py Tue Nov 04 04:48:25 2008 -0800
@@ -32,19 +32,28 @@
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.classes import get_typed_class
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.ReturnCodes import PASS, FAIL, SKIP
from XenKvmLib.common_util import get_host_info
from XenKvmLib.const import get_provider_version
SHAREMODE = 3
REDIRECTION_SER_TYPE = 3
CRS_MAX_SAP_REV = 724
+libvirtcim_hr_crs_changes = 695
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
@do_main(sup_types)
def main():
virt = main.options.virt
server = main.options.ip
+
+ # This check is required for libivirt-cim providers which do not have
+ # CRS changes in it and the CRS provider is available with revision >= 695.
+ curr_cim_rev, changeset = get_provider_version(virt, server)
+ if curr_cim_rev < libvirtcim_hr_crs_changes:
+ logger.info("ConsoleRedirectionService provider not supported, "
+ "hence skipping the tc ....")
+ return SKIP
status, host_name, host_cn = get_host_info(server, virt)
if status != PASS:
16 years, 1 month
[PATCH] [TEST] Updating 02_reverse.py tc of HostedService
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225801400 28800
# Node ID 302c90a9915261a1aebe6e0f20785cb8ccf3caaf
# Parent e0860bbf3ed4cf3d4adb20b5de805ec5ca8818be
[TEST] Updating 02_reverse.py tc of HostedService.
Updating 02_reverse.py tc of HostedService to include CRS provider information
when the libvirt_cim_revision >= 695.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r e0860bbf3ed4 -r 302c90a99152 suites/libvirt-cim/cimtest/HostedService/02_reverse.py
--- a/suites/libvirt-cim/cimtest/HostedService/02_reverse.py Tue Nov 04 03:47:46 2008 -0800
+++ b/suites/libvirt-cim/cimtest/HostedService/02_reverse.py Tue Nov 04 04:23:20 2008 -0800
@@ -31,20 +31,28 @@
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL, XFAIL
from XenKvmLib.common_util import get_host_info
+from XenKvmLib.const import get_provider_version
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
+libvirtcim_hr_crs_changes = 695
@do_main(sup_types)
def main():
options = main.options
+ server = options.ip
virt = options.virt
servicelist = {"ResourcePoolConfigurationService" : "RPCS",
"VirtualSystemManagementService" : "Management Service",
- "VirtualSystemMigrationService" : "MigrationService",
- "ConsoleRedirectionService" : "ConsoleRedirectionService" }
+ "VirtualSystemMigrationService" : "MigrationService"}
- status, host_name, host_ccn = get_host_info(options.ip, virt)
+ # This check is required for libivirt-cim providers which do not have
+ # CRS changes in it and the CRS provider is available with revision >= 695.
+ cim_rev, changeset = get_provider_version(virt, server)
+ if cim_rev >= libvirtcim_hr_crs_changes:
+ servicelist['ConsoleRedirectionService'] = "ConsoleRedirectionService"
+
+ status, host_name, host_ccn = get_host_info(server, virt)
if status != PASS:
logger.error("Failed to get host info.")
return status
@@ -53,7 +61,7 @@
for k, v in servicelist.iteritems():
cn = get_typed_class(virt, k)
try:
- assoc_host = assoc.AssociatorNames(options.ip, an, cn,
+ assoc_host = assoc.AssociatorNames(server, an, cn,
Name = v,
CreationClassName = cn,
SystemCreationClassName = host_ccn,
@@ -63,7 +71,7 @@
return FAIL
if len(assoc_host) != 1:
- logger.error("Too many hosts")
+ logger.error("'%s' association failed", an)
return FAIL
ccn = assoc_host[0].keybindings['CreationClassName']
16 years, 1 month
[PATCH] [TEST] Updating 01_forward.py tc of HostedService
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225798839 28800
# Node ID 257b23f359d1bc274222fa25d0f74b222775fae4
# Parent cd24946b4a7f060f0af9299787dbad3e387d81d6
[TEST] Updating 01_forward.py tc of HostedService.
Updating 01_forward.py tc of HostedService to include CRS provider information
when the libvirt_cim_revision >= 695.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r cd24946b4a7f -r 257b23f359d1 suites/libvirt-cim/cimtest/HostedService/01_forward.py
--- a/suites/libvirt-cim/cimtest/HostedService/01_forward.py Tue Nov 04 01:04:17 2008 -0800
+++ b/suites/libvirt-cim/cimtest/HostedService/01_forward.py Tue Nov 04 03:40:39 2008 -0800
@@ -32,9 +32,11 @@
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
from XenKvmLib.common_util import get_host_info
+from XenKvmLib.const import get_provider_version
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
bug_sblim = '00007'
+libvirtcim_hr_crs_changes = 695
@do_main(sup_types)
def main():
@@ -61,10 +63,17 @@
logger.error("No association return")
return FAIL
- val_serv = Set([get_typed_class(virt, "ResourcePoolConfigurationService"),
- get_typed_class(virt, "VirtualSystemManagementService"),
- get_typed_class(virt, "VirtualSystemMigrationService"),
- get_typed_class(virt, "ConsoleRedirectionService")])
+ val_serv = [get_typed_class(virt, "ResourcePoolConfigurationService"),
+ get_typed_class(virt, "VirtualSystemManagementService"),
+ get_typed_class(virt, "VirtualSystemMigrationService")]
+
+ # This check is required for libivirt-cim providers which do not have
+ # CRS changes in it and the CRS provider is available with revision >= 695.
+ cim_rev, changeset = get_provider_version(virt, server)
+ if cim_rev >= libvirtcim_hr_crs_changes:
+ val_serv.append(get_typed_class(virt, "ConsoleRedirectionService"))
+
+ val_serv = Set(val_serv)
ccn_list = []
for item in service:
16 years, 1 month
[PATCH] [TEST] Fixing 01_forward.py tc of SystemDevice
by Deepti B. Kalakeri
# HG changeset patch
# User Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
# Date 1225568161 25200
# Node ID e92fbb2fe87e11509a5d506f4529368f97ee59cd
# Parent d1614c101c281b57bd2bc98dfb6625f790748e54
[TEST] Fixing 01_forward.py tc of SystemDevice.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r d1614c101c28 -r e92fbb2fe87e suites/libvirt-cim/cimtest/SystemDevice/01_forward.py
--- a/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Wed Oct 29 20:11:47 2008 -0700
+++ b/suites/libvirt-cim/cimtest/SystemDevice/01_forward.py Sat Nov 01 12:36:01 2008 -0700
@@ -28,7 +28,6 @@
from VirtLib import utils
from XenKvmLib import assoc
from XenKvmLib import vxml
-from XenKvmLib import devices
from XenKvmLib.classes import get_typed_class
from CimTest.Globals import logger
from XenKvmLib.const import do_main
@@ -54,7 +53,8 @@
if options.virt == 'LXC':
cxml = virt_xml(test_dom)
else:
- cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac, disk = test_disk)
+ cxml = virt_xml(test_dom, vcpus = test_cpu, mac = test_mac,
+ disk = test_disk)
ret = cxml.create(options.ip)
if not ret:
logger.error('Unable to create domain %s' % test_dom)
@@ -67,39 +67,36 @@
Name=test_dom, CreationClassName=cs_classname)
if devs == None:
logger.error("System association failed")
- return FAIL
- elif len(devs) == 0:
- logger.error("No devices returned")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
return FAIL
+ if len(devs) == 0:
+ logger.error("No devices returned")
+ cxml.destroy(options.ip)
+ cxml.undefine(options.ip)
+ return FAIL
+
+ net_cn = get_typed_class(options.virt, "NetworkPort")
+ mem_cn = get_typed_class(options.virt, "Memory")
+ disk_cn = get_typed_class(options.virt, "LogicalDisk")
+ proc_cn = get_typed_class(options.virt, "Processor")
cn_devid = {
- get_typed_class(options.virt, "NetworkPort") : '%s/%s' % (test_dom, test_mac),
- get_typed_class(options.virt, "Memory") : '%s/mem' % test_dom,
- get_typed_class(options.virt, "LogicalDisk") : '%s/%s' % (test_dom, test_disk),
- get_typed_class(options.virt, "Processor") : '%s/%s' % (test_dom, test_cpu-1)
- }
+ net_cn : '%s/%s' % (test_dom, test_mac),
+ mem_cn : '%s/mem' % test_dom,
+ disk_cn : '%s/%s' % (test_dom, test_disk),
+ proc_cn : '%s/%s' % (test_dom, test_cpu-1)
+ }
- key_list = {'DeviceID' : '',
- 'CreationClassName' : '',
- 'SystemName' : test_dom,
- 'SystemCreationClassname' : cs_classname
- }
-
- for dev_cn in cn_devid.keys():
- for dev in devs:
- key_list['CreationClassName'] = dev['CreationClassname']
- key_list['DeviceID'] = dev['DeviceID']
- device = devices.device_of(options.ip, key_list)
- if device.CreationClassName != dev_cn:
- continue
- devid = device.DeviceID
-
- _devid = cn_devid[dev_cn]
- if devid != _devid:
- logger.error("DeviceID `%s` != `%s'" % (devid, _devid))
- status = FAIL
- else:
- logger.info("Examined %s" % _devid)
+ for dev in devs:
+ dev_cn = dev['CreationClassname']
+ devid = dev['DeviceID']
+ _devid = cn_devid[dev_cn]
+ if devid != _devid:
+ logger.error("DeviceID `%s` != `%s'" % (devid, _devid))
+ status = FAIL
+ else:
+ logger.info("Examined %s" % _devid)
cxml.destroy(options.ip)
cxml.undefine(options.ip)
16 years, 1 month
[PATCH] [TEST]Delete the functions had been moved to xm_virt_util.py in lib/VirtLib/utils.py
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1225777457 28800
# Node ID a6816c4c82d9557d52d93ee0fcc9133d9b03055c
# Parent 8118a0e17d219b6886b34176423c45c855f08576
[TEST]Delete the functions had been moved to xm_virt_util.py in lib/VirtLib/utils.py
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 8118a0e17d21 -r a6816c4c82d9 lib/VirtLib/utils.py
--- a/lib/VirtLib/utils.py Sun Nov 02 19:16:33 2008 -0800
+++ b/lib/VirtLib/utils.py Mon Nov 03 21:44:17 2008 -0800
@@ -111,57 +111,3 @@
cmd = 'python %s %s "%s"' % (CONSOLE_APP_PATH, domain, command)
return run_remote(ip, cmd)
-
-
-def get_xmtest_files(ip, kernel):
- # get the xm-test disk from morbo
- rc, out = run_remote(ip,
- "rm -rf /tmp/boot ; mkdir -p /tmp/boot /tmp/xmtest")
- rc, out = run_remote(ip,
- "cd /tmp/boot ; wget http://morbo.linux.ibm.com/pub/xmtest.disk.gz")
- if rc != 0:
- return 2, "fetching xmtest.disk failed:\n%s" % out
-
- # mount on /tmp/xmtest
- rc, out = run_remote(ip,
- "gzip -d /tmp/boot/xmtest.disk.gz ; mount -o loop /tmp/boot/xmtest.disk /tmp/xmtest")
- if rc != 0:
- run_remote(ip, "umount /tmp/xmtest")
- return 2, "mounting xmtest.disk failed:\n%s" % out
-
- # We need "uname -r" to name the kernel correctly
- rc, uname = run_remote(ip, "uname -r")
- if rc != 0:
- run_remote(ip, "umount /tmp/xmtest")
- return 2, "uname failed:\n%s" % out
-
- # get the kernel binary, put in /tmp/boot
- rc, out = run_remote(ip,
- "wget %s -O /tmp/boot/vmlinuz-\`uname -r\`" % kernel)
- if rc != 0:
- run_remote(ip, "umount /tmp/xmtest")
- return 2, "fetching kernel failed:\n%s" % out
-
- return 0, ""
-
-def customize_xmtest_ramdisk(ip):
- # customize modules on xm-test ramdisk
- # cd $xmtestdir/ramdisk ; bin/add_modules_to_initrd ; cd
- rc, out = run_remote(ip,
- "cd /tmp/xmtest/ramdisk ; bin/add_modules_to_initrd")
- if rc != 0:
- run_remote(ip, "umount /tmp/xmtest")
- return 2, "customizing ramdisk failed:\n%s" % out
-
- return 0, ""
-
-def virt2uri(virt):
- # convert cimtest --virt param string to libvirt uri
- if virt == "Xen" or virt == "XenFV":
- return "xen:///"
- if virt == "KVM":
- return "qemu:///system"
- if virt == "LXC":
- return "lxc:///system"
- return ""
-
16 years, 1 month
[PATCH] [TEST] #2 Move some functions from utils.py to xm_virt_util.py and update helper function
by yunguol@cn.ibm.com
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1225767133 28800
# Node ID 388b8ffc2c4e11fde0ec8373161698b9215811a0
# Parent 8118a0e17d219b6886b34176423c45c855f08576
[TEST] #2 Move some functions from utils.py to xm_virt_util.py and update helper function
Updates from 1 to 2:
run_remote_guest() still stays in lib/VirtLib/utils.py.
If you think it has to be moved to xm_virt_util.py, follow up patch will do this.
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 8118a0e17d21 -r 388b8ffc2c4e suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Nov 03 18:52:13 2008 -0800
@@ -36,7 +36,8 @@
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, \
CIM_ERROR_GETINSTANCE
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
-from XenKvmLib.xm_virt_util import diskpool_list, virsh_version, net_list, domain_list
+from XenKvmLib.xm_virt_util import diskpool_list, virsh_version, net_list,\
+ domain_list, virt2uri
from XenKvmLib.vxml import PoolXML, NetXML
from VirtLib import utils
from XenKvmLib.const import default_pool_name, default_network_name
@@ -382,7 +383,7 @@
if dpoolname == None:
cmd = "virsh -c %s pool-list --all | grep %s" % \
- (utils.virt2uri(virt), dpool)
+ (virt2uri(virt), dpool)
ret, out = utils.run_remote(server, cmd)
if out != "":
logger.error("Disk pool with name '%s' already exists", dpool)
@@ -444,7 +445,7 @@
if test_network == None:
cmd = "virsh -c %s net-list --all | grep -w %s" % \
- (utils.virt2uri(virt), net_name)
+ (virt2uri(virt), net_name)
ret, out = utils.run_remote(server, cmd)
# If success, network pool with name net_name already exists
if ret == 0:
diff -r 8118a0e17d21 -r 388b8ffc2c4e suites/libvirt-cim/lib/XenKvmLib/test_doms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/test_doms.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/test_doms.py Mon Nov 03 18:52:13 2008 -0800
@@ -24,7 +24,7 @@
import tempfile
import os
from VirtLib import utils
-from XenKvmLib.xm_virt_util import domain_list
+from XenKvmLib.xm_virt_util import domain_list, virt2uri
from CimTest.Globals import CIM_FUUID
try:
@@ -47,19 +47,19 @@
f.write(xml)
f.close()
- cmd = "virsh -c %s define %s" % (utils.virt2uri(virt), name)
+ cmd = "virsh -c %s define %s" % (virt2uri(virt), name)
s, o = utils.run_remote(server, cmd)
return s == 0
def undefine_test_domain(name, server, virt="Xen"):
- cmd = "virsh -c %s undefine %s" % (utils.virt2uri(virt), name)
+ cmd = "virsh -c %s undefine %s" % (virt2uri(virt), name)
s, o = utils.run_remote(server, cmd)
return s == 0
def start_test_domain(name, server, virt="Xen"):
- cmd = "virsh -c %s start %s" % (utils.virt2uri(virt), name)
+ cmd = "virsh -c %s start %s" % (virt2uri(virt), name)
s, o = utils.run_remote(server, cmd)
return s == 0
@@ -68,7 +68,7 @@
"""Get a list of domid from virsh"""
cmd = "virsh -c %s list 2>/dev/null | sed '1,2 d; /^$/d'" % \
- utils.virt2uri(virt)
+ virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
return None
@@ -109,7 +109,7 @@
def viruuid(name, server, virt="Xen"):
"""Return domain uuid given domid or domname"""
cmd = "virsh -c %s domuuid %s 2>/dev/null | sed '/^$/d'" % \
- (utils.virt2uri(virt), name)
+ (virt2uri(virt), name)
ret, out = utils.run_remote(server, cmd)
if ret == 0:
return out.strip(" \n")
@@ -120,7 +120,7 @@
"""Destroy and undefine a domain.
name could be domid or domname"""
cmd = "virsh -c %s 'destroy %s ; undefine %s'" % \
- (utils.virt2uri(virt), name, name)
+ (virt2uri(virt), name, name)
utils.run_remote(server, cmd)
def destroy_and_undefine_all(server, virt="Xen", aggressive = False):
@@ -154,7 +154,7 @@
else:
name = xmlfile_domname
- vcmd = "virsh -c %s %s %s" % (utils.virt2uri(virt), cmd, name)
+ vcmd = "virsh -c %s %s %s" % (virt2uri(virt), cmd, name)
s, o = utils.run_remote(server, vcmd)
if cmd == "define" or cmd == "create":
f.close()
@@ -165,7 +165,7 @@
Get the vcpu lists. The input is either the domid or domname.
"""
cmd = "virsh -c %s vcpuinfo %s | grep '^$' | wc -l" % \
- (utils.virt2uri(virt), name_id)
+ (virt2uri(virt), name_id)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -180,7 +180,7 @@
nf.write(net_xml)
nf.flush()
fname = nf.name
- cmd = "virsh -c %s net-create %s" % (utils.virt2uri(virt), fname)
+ cmd = "virsh -c %s net-create %s" % (virt2uri(virt), fname)
ret, out = utils.run_remote(server, cmd)
nf.close()
if ret != 0:
diff -r 8118a0e17d21 -r 388b8ffc2c4e suites/libvirt-cim/lib/XenKvmLib/test_xml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/test_xml.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/test_xml.py Mon Nov 03 18:52:13 2008 -0800
@@ -35,7 +35,7 @@
from XenKvmLib.test_doms import set_uuid, create_vnet
from VirtLib.live import available_bridges
from XenKvmLib.xm_virt_util import net_list, get_bridge_from_network_xml, \
- bootloader
+ bootloader, virt2uri
from CimTest.ReturnCodes import SKIP
image_dir = "/tmp"
@@ -201,7 +201,7 @@
def dumpxml(name, server, virt="Xen"):
- cmd = "virsh -c %s dumpxml %s" % (utils.virt2uri(virt), name)
+ cmd = "virsh -c %s dumpxml %s" % (virt2uri(virt), name)
s, o = utils.run_remote(server, cmd)
if s == 0:
return o
diff -r 8118a0e17d21 -r 388b8ffc2c4e suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py Mon Nov 03 18:52:13 2008 -0800
@@ -63,7 +63,7 @@
"""
guest_cmd = "cat /proc/partitions | awk '/^ /{ print $4 } ' "
- rc, out = utils.run_remote_guest(ip, vs_name, guest_cmd)
+ rc, out = run_remote_guest(ip, vs_name, guest_cmd)
if rc != 0:
return None
@@ -89,7 +89,7 @@
virt = "Xen"
cmd = "virsh -c %s list --all | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
+ virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -109,7 +109,7 @@
virt = "Xen"
cmd = "virsh -c %s list | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
+ virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -156,7 +156,7 @@
"""Function to list active network"""
names = []
cmd = "virsh -c %s net-list | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
+ virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -173,7 +173,7 @@
"""Function returns bridge name for a given virtual network"""
cmd = "virsh -c %s net-dumpxml %s | awk '/bridge name/ { print $2 }'" % \
- (utils.virt2uri(virt), network)
+ (virt2uri(virt), network)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -196,7 +196,7 @@
return None
def virsh_version(server, virt="KVM"):
- cmd = "virsh -c %s -v " % utils.virt2uri(virt)
+ cmd = "virsh -c %s -v " % virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
return None
@@ -206,7 +206,7 @@
"""Function to list active DiskPool list"""
names = []
cmd = "virsh -c %s pool-list | sed -e '1,2 d' -e '$ d'" % \
- utils.virt2uri(virt)
+ virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret != 0:
@@ -221,7 +221,7 @@
return names
def virsh_vcpuinfo(server, dom, virt="Xen"):
- cmd = "virsh -c %s vcpuinfo %s | grep VCPU | wc -l" % (utils.virt2uri(virt),
+ cmd = "virsh -c %s vcpuinfo %s | grep VCPU | wc -l" % (virt2uri(virt),
dom)
ret, out = utils.run_remote(server, cmd)
if out.isdigit():
@@ -229,10 +229,61 @@
return None
def get_hv_ver(server, virt="Xen"):
- cmd = "virsh -c %s version | grep ^Running | cut -d ' ' -f 3,4" % utils.virt2uri(virt)
+ cmd = "virsh -c %s version | grep ^Running | cut -d ' ' -f 3,4" %virt2uri(virt)
ret, out = utils.run_remote(server, cmd)
if ret == 0:
return out
else:
return None
+def get_xmtest_files(ip, kernel):
+ # get the xm-test disk from morbo
+ rc, out = run_remote(ip,
+ "rm -rf /tmp/boot ; mkdir -p /tmp/boot /tmp/xmtest")
+ rc, out = run_remote(ip,
+ "cd /tmp/boot ; wget http://morbo.linux.ibm.com/pub/xmtest.disk.gz")
+ if rc != 0:
+ return 2, "fetching xmtest.disk failed:\n%s" % out
+
+ # mount on /tmp/xmtest
+ rc, out = run_remote(ip,
+ "gzip -d /tmp/boot/xmtest.disk.gz ; mount -o loop /tmp/boot/xmtest.disk /tmp/xmtest")
+ if rc != 0:
+ run_remote(ip, "umount /tmp/xmtest")
+ return 2, "mounting xmtest.disk failed:\n%s" % out
+
+ # We need "uname -r" to name the kernel correctly
+ rc, uname = run_remote(ip, "uname -r")
+ if rc != 0:
+ run_remote(ip, "umount /tmp/xmtest")
+ return 2, "uname failed:\n%s" % out
+
+ # get the kernel binary, put in /tmp/boot
+ rc, out = run_remote(ip,
+ "wget %s -O /tmp/boot/vmlinuz-\`uname -r\`" % kernel)
+ if rc != 0:
+ run_remote(ip, "umount /tmp/xmtest")
+ return 2, "fetching kernel failed:\n%s" % out
+
+ return 0, ""
+
+def customize_xmtest_ramdisk(ip):
+ # customize modules on xm-test ramdisk
+ # cd $xmtestdir/ramdisk ; bin/add_modules_to_initrd ; cd
+ rc, out = run_remote(ip,
+ "cd /tmp/xmtest/ramdisk ; bin/add_modules_to_initrd")
+ if rc != 0:
+ run_remote(ip, "umount /tmp/xmtest")
+ return 2, "customizing ramdisk failed:\n%s" % out
+
+ return 0, ""
+
+def virt2uri(virt):
+ # convert cimtest --virt param string to libvirt uri
+ if virt == "Xen" or virt == "XenFV":
+ return "xen:///"
+ if virt == "KVM":
+ return "qemu:///system"
+ if virt == "LXC":
+ return "lxc:///system"
+ return ""
diff -r 8118a0e17d21 -r 388b8ffc2c4e suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py Sun Nov 02 19:16:33 2008 -0800
+++ b/suites/libvirt-cim/main.py Mon Nov 03 18:52:13 2008 -0800
@@ -36,6 +36,7 @@
default_pool_name
from XenKvmLib.reporting import gen_report, send_report
from VirtLib import utils
+from XenKvmLib.xm_virt_util import virt2uri
from CimTest.ReturnCodes import PASS, FAIL
from XenKvmLib.common_util import create_netpool_conf, destroy_netpool, \
create_diskpool_conf, destroy_diskpool
@@ -90,12 +91,12 @@
print "Cleaned log files."
def pre_check(ip, virt):
- cmd = "virsh -c %s list --all" % utils.virt2uri(virt)
+ cmd = "virsh -c %s list --all" % virt2uri(virt)
ret, out = utils.run_remote(ip, cmd)
if ret != 0:
return "This libvirt install does not support %s" % virt
- cmd = "virsh -c %s version" % utils.virt2uri(virt)
+ cmd = "virsh -c %s version" % virt2uri(virt)
ret, out = utils.run_remote(ip, cmd)
if ret != 0:
return "Encountered an error querying libvirt with: %s" % cmd
16 years, 1 month