import logger
import bwlimit
-import sliver_libvirt
+from sliver_libvirt import Sliver_Libvirt
-class Sliver_LXC(sliver_libvirt.Sliver_Libvirt):
+class Sliver_LXC(Sliver_Libvirt):
"""This class wraps LXC commands"""
SHELL = '/bin/sshsh'
def create(name, rec=None):
''' Create dirs, copy fs image, lxc_create '''
logger.verbose ('sliver_lxc: %s create'%(name))
- conn = sliver_libvirt.getConnection(Sliver_LXC.TYPE)
+ conn = Sliver_Libvirt.getConnection(Sliver_LXC.TYPE)
# Get the type of image from vref myplc tags specified as:
# pldistro = lxc
# password... maybe remove the need for authentication inside the
# guest?
command = ['su', '-s', '/bin/bash', '-c', 'ssh-keygen -t rsa -N "" -f /home/%s/.ssh/id_rsa'%(name)]
- logger.log_call(command, timeout=15*60)
+ logger.log_call(command, timeout=60)
command = ['chown', '-R', '%s.slices'%name, '/home/%s/.ssh'%name]
- logger.log_call(command, timeout=15*60)
+ logger.log_call(command, timeout=30)
command = ['mkdir', '%s/root/.ssh'%containerDir]
- logger.log_call(command, timeout=15*60)
+ logger.log_call(command, timeout=10)
command = ['cp', '/home/%s/.ssh/id_rsa.pub'%name, '%s/root/.ssh/authorized_keys'%containerDir]
- logger.log_call(command, timeout=15*60)
+ logger.log_call(command, timeout=30)
# Lookup for xid and create template after the user is created so we
# can get the correct xid based on the name of the slice
dom = conn.lookupByName(name)
except:
dom = conn.defineXML(xml)
- logger.verbose('lxc_create: %s -> %s'%(name, sliver_libvirt.debuginfo(dom)))
+ logger.verbose('lxc_create: %s -> %s'%(name, Sliver_Libvirt.debuginfo(dom)))
@staticmethod
def destroy(name):
logger.verbose ('sliver_lxc: %s destroy'%(name))
- conn = sliver_libvirt.getConnection(Sliver_LXC.TYPE)
+ conn = Sliver_Libvirt.getConnection(Sliver_LXC.TYPE)
containerDir = Sliver_LXC.CON_BASE_DIR + '/%s'%(name)
# Remove rootfs of destroyed domain
command = ['btrfs', 'subvolume', 'delete', containerDir]
- logger.log_call(command, timeout=15*60)
+ logger.log_call(command, timeout=60)
logger.verbose('sliver_libvirt: %s destroyed.'%name)