# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1208332735 -28800
# Node ID 32614eca2a5579389cc5b262eff8243b0ca2da82
# Parent 7c20d87e25c0cd53deba4dc8c48529d84bb740d9
[TEST] KVMXML cim_define() support and KVM support for Profile.02
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 7c20d87e25c0 -r 32614eca2a55
suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py
--- a/suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py Wed Apr 16 15:04:54 2008
+0800
+++ b/suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py Wed Apr 16 15:58:55 2008
+0800
@@ -47,16 +47,17 @@ from CimTest.Globals import do_main
from CimTest.Globals import do_main
from CimTest.ReturnCodes import PASS, FAIL
-sup_types = ['Xen']
+sup_types = ['Xen', 'KVM']
test_dom = "domguest"
+
+rp_cn = 'RegisteredProfile'
def setup_env(server):
rc = -1
status = PASS
csxml_info = None
try:
- destroy_and_undefine_all(server)
virt_xml = get_class(virt)
csxml_info = virt_xml(test_dom)
rc = csxml_info.cim_define(server)
@@ -76,100 +77,54 @@ def print_err(err, detail, cn):
logger.error(err % cn)
logger.error("Exception: %s", detail)
-def get_inst_from_list(server, cn, qcn, list, filter, exp_val):
- status = PASS
- ret = -1
- inst = None
-
- if len(list) < 1:
- logger.error("%s returned %i %s objects" % (qcn, len(list), cn))
- return FAIL, None
-
- for inst in list:
- if inst[filter['key']] == exp_val:
- ret = PASS
- break
-
- if ret != PASS:
- status = FAIL
- logger.error("%s with %s was not returned" % (cn, exp_val))
-
- return PASS, inst
+def get_expected_inst(list, property, exp):
+ try:
+ for x in list:
+ if x[property] == exp:
+ return PASS, x
+ except Exception:
+ pass
+ return FAIL, None
def get_profile(server):
registeredname = 'Virtual System Profile'
- cn = 'Xen_RegisteredProfile'
status = PASS
profile = None
try:
- proflist = enumclass.enumerate_inst(server,
- enumclass.Xen_RegisteredProfile)
-
- filter = {"key" : "RegisteredName"}
- status, profile = get_inst_from_list(server,
- cn,
- cn,
- proflist,
- filter,
- registeredname)
-
+ proflist = enumclass.enumerate_inst(server, rp_cn, virt)
+ status, profile = get_expected_inst(proflist, 'RegisteredName',
+ registeredname)
except Exception, detail:
- print_err(CIM_ERROR_ENUMERATE, detail, cn)
+ print_err(CIM_ERROR_ENUMERATE, detail, rp_cn)
status = FAIL
-
return status, profile
def get_cs(server, profile):
- cn = 'Xen_RegisteredProfile'
- an = 'Xen_ElementConformsToProfile'
+ an = 'ElementConformsToProfile'
status = PASS
cs = None
try:
- assoc_info = Associators(server,
- an,
- cn,
+ assoc_info = Associators(server, an, rp_cn, virt,
InstanceID = profile['InstanceID'])
-
- cn = 'Xen_ComputerSystem'
- filter = {"key" : "Name"}
- status, cs = get_inst_from_list(server,
- cn,
- an,
- assoc_info,
- filter,
- test_dom)
-
+ status, cs = get_expected_inst(assoc_info, 'Name', test_dom)
except Exception, detail:
print_err(CIM_ERROR_ASSOCIATORNAMES, detail, cn)
status = FAIL
-
return status, cs
def get_elec(server, cs):
- cn = 'Xen_ComputerSystem'
- an = 'Xen_ElementCapabilities'
+ cn = 'ComputerSystem'
+ an = 'ElementCapabilities'
status = FAIL
elec = None
ccn = cs['CreationClassName']
try:
- assoc_info = Associators(server,
- an,
- cn,
- Name = cs['Name'],
- CreationClassName = ccn)
-
- cn = 'Xen_EnabledLogicalElementCapabilities'
- filter = {"key" : "InstanceID"}
- status, elec = get_inst_from_list(server,
- cn,
- an,
- assoc_info,
- filter,
- test_dom)
-
+ assoc_info = Associators(server, an, cn, virt, Name=cs['Name'],
+ CreationClassName=ccn)
+ status, elec = get_expected_inst(assoc_info, 'InstanceID', test_dom)
except Exception, detail:
print_err(CIM_ERROR_ASSOCIATORNAMES, detail, cn)
status = FAIL
diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 16 15:04:54 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 16 15:58:55 2008 +0800
@@ -443,11 +443,10 @@ class XenXML(VirtXML, VirtCIM):
'Either the kernel image or the init_path does not exist')
sys.exit(1)
VirtXML.__init__(self, 'xen', test_dom, set_uuid(), mem, vcpus)
+ VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path,
+ const.Xen_default_net_type, mac, vcpus, mem)
self._os(const.Xen_kernel_path, const.Xen_init_path)
self._devices(disk_file_path, disk, const.Xen_default_net_type, mac)
-
- VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path,
- const.Xen_default_net_type, mac, vcpus, mem)
def _os(self, os_kernel, os_initrd):
os = self.get_node('/domain/os')
@@ -482,7 +481,7 @@ class XenXML(VirtXML, VirtCIM):
return self._set_vbridge(ip, 'Xen')
-class KVMXML(VirtXML):
+class KVMXML(VirtXML, VirtCIM):
secondary_disk_path = const.KVM_secondary_disk_path
@@ -496,6 +495,8 @@ class KVMXML(VirtXML):
logger.error('Error: Disk image does not exist')
sys.exit(1)
VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus)
+ VirtCIM.__init__(self, 'KVM', test_dom, disk, disk_file_path,
+ const.KVM_default_net_type, mac, vcpus, mem)
self._os()
self._devices(const.KVM_default_emulator, const.KVM_default_net_type,
disk_file_path, disk, mac)
@@ -519,9 +520,11 @@ class KVMXML(VirtXML):
return self._set_emulator(emu)
def set_bridge(self, ip):
+ self.nasd.NetworkType = 'bridge'
return self._set_bridge(ip)
def set_vbridge(self, ip):
+ self.nasd.NetworkType = 'bridge'
return self._set_vbridge(ip, 'KVM')