From 05970254a08d528fff89747c1becb1c3fd565d9c Mon Sep 17 00:00:00 2001 From: zhuyj17 Date: Sun, 8 Apr 2018 17:02:09 +0800 Subject: [PATCH] Use db when start and stop clusters --- src/vclustermgr.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/vclustermgr.py b/src/vclustermgr.py index 59c1450..572c588 100755 --- a/src/vclustermgr.py +++ b/src/vclustermgr.py @@ -611,9 +611,10 @@ class VclusterMgr(object): namesplit = container['containername'].split('-') portname = namesplit[1] + '-' + namesplit[2] worker.recover_usernet(portname, uid, info['proxy_server_ip'], container['host']==info['proxy_server_ip']) - info['status']='running' - info['start_time']=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - self.write_clusterinfo(info,clustername,username) + [status,vcluster] = self.get_vcluster(clustername,username) + vcluster.status ='running' + vcluster.start_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + db.session.commit() return [True, "start cluster"] def mount_cluster(self, clustername, username): @@ -692,12 +693,10 @@ class VclusterMgr(object): if worker is None: return [False, "The worker can't be found or has been stopped."] worker.stop_container(container['containername']) - [status, info] = self.get_clusterinfo(clustername, username) - info['status']='stopped' - info['start_time']="------" - infofile = open(self.fspath+"/global/users/"+username+"/clusters/"+clustername, 'w') - infofile.write(json.dumps(info)) - infofile.close() + [status, vcluster] = self.get_vcluster(clustername, username) + vcluster.status = 'stopped' + vcluster.start_time ="------" + db.session.commit() return [True, "stop cluster"] def detach_cluster(self, clustername, username):