From: Xavi Leon Date: Thu, 10 Nov 2011 15:42:10 +0000 (-0500) Subject: Merge branch 'lxc_devel' of github.com:planetlab/NodeManager into lxc_devel X-Git-Tag: lxcbuild~4 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2fbc810bde9fa8b3acb277f4d6157341073c7b6a;p=nodemanager.git Merge branch 'lxc_devel' of github.com:planetlab/NodeManager into lxc_devel Conflicts: sliver_libvirt.py --- 2fbc810bde9fa8b3acb277f4d6157341073c7b6a diff --cc sliver_libvirt.py index d835336,8456d95..b991556 --- a/sliver_libvirt.py +++ b/sliver_libvirt.py @@@ -50,27 -56,28 +56,32 @@@ class Sliver_LV(accounts.Account) # arch x86_64 vref = rec['vref'] if vref is None: - logger.log("sliver_libvirt: %s: WARNING - no vref attached defaults to lxc-debian"%(name)) + logger.log('sliver_libvirt: %s: WARNING - no vref attached defaults to lxc-debian' % (name)) vref = "lxc-squeeze-x86_64" + refImgDir = os.path.join(REF_IMG_BASE_DIR, vref) + containerDir = os.path.join(CON_BASE_DIR, name) + # check the template exists -- there's probably a better way.. - if not os.path.isdir ("/vservers/.lvref/%s"%vref): - logger.log ("sliver_libvirt: %s: ERROR Could not create sliver - reference image %s not found"%(name,vref)) + if not os.path.isdir(refImgDir): + logger.log('sliver_libvirt: %s: ERROR Could not create sliver - reference image %s not found' % (name,vref)) return - + # Copy the reference image fs # shutil.copytree("/vservers/.lvref/%s"%vref, "/vservers/%s"%name, symlinks=True) - command = ['cp', '-r', '/vservers/.lvref/%s'%vref, '/vservers/%s'%name] + command = ['cp', '-r', refImgDir, containerDir] logger.log_call(command, timeout=15*60) - # Set hostname - file('/vservers/%s/etc/hostname' % name, 'w').write(name) - + # Set hostname. A valid hostname cannot have '_' + with open(os.path.join(containerDir, 'etc/hostname'), 'w') as f: + print >>f, name.replace('_', '-') + + # Add slices group if not already present + command = ['/usr/sbin/groupadd slices'] + logger.log_call(command, timeout=15*60) ++ # Add unix account - command = ['/usr/sbin/useradd', '-s', '/bin/sh', name] + command = ['/usr/sbin/useradd', '-g', 'slices', '-s', '/bin/sh', name, '-p', '*'] logger.log_call(command, timeout=15*60) # Get a connection and lookup for the sliver before actually