# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1212085020 -28800
# Node ID 555aeb0c467907a683e208d87ec67bb083d3d9e0
# Parent 9520aaa2b61210bb2038b5bf3be5bed3b711c78e
[TEST] LXC support using DefineSystem & VSMS.01
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 9520aaa2b612 -r 555aeb0c4679
suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py
---
a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Fri
May 30 00:30:02 2008 +0800
+++
b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/01_definesystem_name.py Fri
May 30 02:17:00 2008 +0800
@@ -30,7 +30,7 @@
from CimTest.Globals import do_main
from CimTest.Globals import logger
-SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV']
+SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
default_dom = 'test_domain'
@do_main(SUPPORTED_TYPES)
diff -r 9520aaa2b612 -r 555aeb0c4679 suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 30 00:30:02 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Fri May 30 02:17:00 2008 +0800
@@ -85,3 +85,4 @@
#vxml.LXCXML
LXC_init_path = os.path.join(_image_dir, 'cimtest_lxc_init')
LXC_default_tty = '/dev/ptmx'
+LXC_default_mp = '/tmp'
diff -r 9520aaa2b612 -r 555aeb0c4679 suites/libvirt-cim/lib/XenKvmLib/vsms.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri May 30 00:30:02 2008 +0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Fri May 30 02:17:00 2008 +0800
@@ -66,6 +66,9 @@
class KVM_VirtualSystemManagementService(CIM_VirtualSystemManagementService):
pass
+class LXC_VirtualSystemManagementService(CIM_VirtualSystemManagementService):
+ pass
+
@eval_cls('VirtualSystemManagementService')
def get_vsms_class(virt):
pass
@@ -99,6 +102,8 @@
self.isFullVirt = (type == 'KVM' or virt == 'XenFV')
if self.isFullVirt:
self.BootDevice = 'hd'
+ elif type == 'LXC':
+ self.InitPath = const.LXC_init_path
else:
self.Bootloader = live.bootloader(Globals.CIM_IP, 0)
self.BootloaderArgs = ''
@@ -110,6 +115,9 @@
pass
class KVM_VirtualSystemSettingData(CIM_VirtualSystemSettingData):
+ pass
+
+class LXC_VirtualSystemSettingData(CIM_VirtualSystemSettingData):
pass
@eval_cls('VirtualSystemSettingData')
@@ -131,6 +139,11 @@
class KVM_DiskResourceAllocationSettingData(CIM_DiskResourceAllocationSettingData):
pass
+
+class LXC_DiskResourceAllocationSettingData(CIMClassMOF):
+ def __init__(self, mountpoint, name):
+ self.MountPoint = mountpoint
+ self.InstanceID = '%s/%s' % (name, mountpoint)
@eval_cls('DiskResourceAllocationSettingData')
def get_dasd_class(virt):
@@ -154,6 +167,9 @@
class KVM_NetResourceAllocationSettingData(CIM_NetResourceAllocationSettingData):
pass
+class LXC_NetResourceAllocationSettingData(CIM_NetResourceAllocationSettingData):
+ pass
+
@eval_cls('NetResourceAllocationSettingData')
def get_nasd_class(virt):
pass
@@ -172,6 +188,9 @@
pass
class KVM_ProcResourceAllocationSettingData(CIM_ProcResourceAllocationSettingData):
+ pass
+
+class LXC_ProcResourceAllocationSettingData(CIM_ProcResourceAllocationSettingData):
pass
@eval_cls('ProcResourceAllocationSettingData')
@@ -194,6 +213,9 @@
class KVM_MemResourceAllocationSettingData(CIM_MemResourceAllocationSettingData):
pass
+class LXC_MemResourceAllocationSettingData(CIM_MemResourceAllocationSettingData):
+ pass
+
@eval_cls('MemResourceAllocationSettingData')
def get_masd_class(virt):
pass
@@ -208,18 +230,25 @@
virt='Xen'):
class_vssd = get_vssd_class(virt)
vssd = class_vssd(name=dom_name, virt=virt)
+
+ # LXC only takes disk and memory device for now.
+ # Only disk __init__ takes different params.
+ if virt == 'LXC':
+ d = LXC_DiskResourceAllocationSettingData(
+ mountpoint=const.LXC_default_mp, name=dom_name)
+ else:
+ class_dasd = get_dasd_class(virt)
+ if virt == 'KVM':
+ disk_dev = 'hda'
+ disk_source = const.KVM_disk_path
+ elif virt == 'XenFV':
+ disk_dev = 'hda'
+ disk_source = const.XenFV_disk_path
+ d = class_dasd(
+ dev=disk_dev,
+ source=disk_source,
+ name=dom_name)
- class_dasd = get_dasd_class(virt)
- if virt == 'KVM':
- disk_dev = 'hda'
- disk_source = const.KVM_disk_path
- elif virt == 'XenFV':
- disk_dev = 'hda'
- disk_source = const.XenFV_disk_path
- d = class_dasd(
- dev=disk_dev,
- source=disk_source,
- name=dom_name)
class_nasd = get_nasd_class(virt)
if virt == 'KVM':
net_mac= const.KVM_default_mac
@@ -237,6 +266,6 @@
m = class_masd(
megabytes=mem_mb,
name=dom_name)
-
+
return vssd.mof(), [d.mof(), n.mof(), p.mof(), m.mof()]