def installXl(self, args = None):
fd = open(self.config['template'])
lvmDev = imp.load_source('xlConfig', '', fd).disk[0].split(',')[0][4:]
fd.close()
templateArgs = args.split(' ') if args is not None else []
xl = subprocess.Popen(
['/usr/share/xen/templates/xen-%s' % (self.template), '--hostname=%s' % (self.name), '--dev=%s' % (lvmDev)] + templateArgs,
stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE
)
stdOut, stdErr = xl.communicate()
if xl.returncode == 0:
if not os.path.exists('/var/lib/xen/%s' % (self.name)):
os.mkdir('/var/lib/xen/%s' % (self.name), 0750)
copyfile(self.config['template'], self.config['file'])
self.state = self.getXlState()
return True
else:
return False
评论列表
文章目录