Use lxc-start cmd instead of lxc api

This commit is contained in:
zhuyj17 2019-01-07 00:07:24 +08:00
parent 55329894b7
commit 8fc02b2137
1 changed files with 5 additions and 2 deletions

View File

@ -273,8 +273,11 @@ class TaskController(rpc_pb2_grpc.WorkerServicer):
conffile.write("\n"+ mount_str % (self.fspath, username, mount.remotePath, rootfs, mount.remotePath))
conffile.close()
container = lxc.Container(lxcname)
if not container.start():
logger.info("Start container %s..." % lxcname)
#container = lxc.Container(lxcname)
ret = subprocess.run('lxc-start -n %s'%lxcname,stdout=subprocess.PIPE,stderr=subprocess.STDOUT, shell=True)
if ret.returncode != 0:
logger.error('start container %s failed' % lxcname)
self.release_ip(ip)
self.imgmgr.deleteFS(lxcname)