# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1210745379 25200
# Node ID 6a8318103e42f7e1891011550d3a9f7d7f86839c
# Parent 935b2c485f8857ddb396efd729d5fc7ff7b41614
[TEST] add LXCXML class to support LXC guest
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt-cim/lib/XenKvmLib/const.py
--- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 22:57:46 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 13 23:09:39 2008 -0700
@@ -78,3 +78,9 @@ XenFV_default_disk_dev = 'hda'
XenFV_default_disk_dev = 'hda'
XenFV_default_mac = '00:16:3e:5d:c7:9e'
XenFV_default_net_type = 'bridge'
+
+#vxml.LXCXML
+LXC_init_path = os.path.join(_image_dir)
+LXC_default_file_src = '/tmp'
+LXC_default_file_tar = '/tmp'
+LXC_default_tty = '/tmp'
diff -r 935b2c485f88 -r 6a8318103e42 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 22:57:46 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 13 23:09:39 2008 -0700
@@ -141,6 +141,8 @@ class Virsh:
self.vuri = 'xen:///'
elif vir_type == 'kvm':
self.vuri = 'qemu:///system'
+ elif vir_type == 'lxc':
+ self.vuri = 'lxc:///system'
def run(self, ip, vcmd, param):
file_arg_cmds = ['define', 'create', 'net-create']
@@ -246,7 +248,7 @@ class VirtXML(Virsh, XMLClass):
raise NotImplementedError('virtual method, implement your own')
def issubinstance(self):
- return isinstance(self, (XenXML, KVMXML, XenFVXML))
+ return isinstance(self, (XenXML, KVMXML, XenFVXML, LXCXML))
def set_memory(self, mem):
self.set_cdata('/domain/memory', mem * 1024)
@@ -593,6 +595,35 @@ class XenFVXML(VirtXML):
def set_vbridge(self, ip):
return self._set_vbridge(ip, 'XenFV')
+class LXCXML(VirtXML):
+
+ def __init__(self, test_dom=const.default_domname,
+ mem=const.default_memory,
+ vcpus=const.default_vcpus,
+ file_path_src=const.LXC_default_file_src,
+ file_path_tar=const.LXC_default_file_tar,
+ tty=const.LXC_default_tty):
+ if not os.path.exists(const.LXC_init_path):
+ logger.error('ERROR: init_path does not exist')
+ sys.exit(1)
+ VirtXML.__init__(self, 'lxc', test_dom, set_uuid(), mem, vcpus)
+ self._os(const.LXC_init_path)
+ self._devices(const.LXC_default_file_src,
+ const.LXC_default_file_tar,
+ const.LXC_default_tty)
+
+ def _os(self, os_init):
+ os = self.get_node('/domain/os')
+ self.add_sub_node(os, 'init', os_init)
+
+ def _devices(self, file_src, file_tar, tty):
+ devices = self.get_node('/domain/devices')
+
+ disk = self.add_sub_node(devices, 'filesystem', type='mount')
+ self.add_sub_node(disk, 'source', dir=file_src)
+ self.add_sub_node(disk, 'target', dir=file_tar)
+
+ interface = self.add_sub_node(devices, 'console', tty)
def get_class(virt):
if virt in virt_types: