[PATCH 0 of 3] [TEST] #2 resubmit LXC support for cimtest, mainly modified LXCXML description based on Kaitlin's suggestion

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1211269259 25200 # Node ID 5f0a469e6a9a1fe02cc26a9f81e87a80286a43d5 # Parent b2b2bb6cc8d87ba0eeddcf3d361d3085104d3492 [TEST] add lxc file creation function Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r b2b2bb6cc8d8 -r 5f0a469e6a9a suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon May 19 10:43:33 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue May 20 00:40:59 2008 -0700 @@ -359,3 +359,16 @@ def create_netpool_conf(server, virt): logger.error("Exception: In fn create_netpool_conf(): %s", detail) status=FAIL return status, test_network + +def create_lxc_file(lxc_file): + status = PASS + try: + f = open(lxc_file, 'w') + f.write('%s' % 'exec /bin/sh') + f.close() + except Exception,detail: + logger.error("Exception: %s", detail) + + if status != PASS: + logger.error("Creation of LXC file Failed") + return status

Guo Lian Yun wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1211269259 25200 # Node ID 5f0a469e6a9a1fe02cc26a9f81e87a80286a43d5 # Parent b2b2bb6cc8d87ba0eeddcf3d361d3085104d3492 [TEST] add lxc file creation function
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r b2b2bb6cc8d8 -r 5f0a469e6a9a suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon May 19 10:43:33 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue May 20 00:40:59 2008 -0700 @@ -359,3 +359,16 @@ def create_netpool_conf(server, virt): logger.error("Exception: In fn create_netpool_conf(): %s", detail) status=FAIL return status, test_network + +def create_lxc_file(lxc_file): + status = PASS + try: + f = open(lxc_file, 'w') + f.write('%s' % 'exec /bin/sh') + f.close() + except Exception,detail: + logger.error("Exception: %s", detail) + + if status != PASS:
status doesn't get set to FAIL in this function, so this function will always pass. Also, you'll need to modify the permissions of the script so that it is an executable. Otherwise, the container will be unable to run the script.
+ logger.error("Creation of LXC file Failed") + return status
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1211269346 25200 # Node ID ff2aace1f86d0bd810dd20c5093c579873695681 # Parent 5f0a469e6a9a1fe02cc26a9f81e87a80286a43d5 [TEST] set lxc default value in const.py Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 5f0a469e6a9a -r ff2aace1f86d suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 20 00:40:59 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Tue May 20 00:42:26 2008 -0700 @@ -81,3 +81,7 @@ 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, 'cimtest_lxc_init') +LXC_default_tty = '/dev/ptmx'

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1211269445 25200 # Node ID aa2d643c9807396aa429d641ab4cef4e5c2997fd # Parent ff2aace1f86d0bd810dd20c5093c579873695681 [TEST] add LXCXML class in vxml.py Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r ff2aace1f86d -r aa2d643c9807 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 20 00:42:26 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue May 20 00:44:05 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', 'pool-create', 'pool-destroy'] @@ -280,7 +282,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) @@ -627,6 +629,27 @@ 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, + 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_tty) + + def _os(self, os_init): + os = self.get_node('/domain/os') + self.add_sub_node(os, 'init', os_init) + + def _devices(self, tty): + devices = self.get_node('/domain/devices') + + interface = self.add_sub_node(devices, 'console', tty) def get_class(virt): if virt in virt_types:
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert