diff --git a/src/network.py b/src/network.py index b3c0ea6..fe3c412 100755 --- a/src/network.py +++ b/src/network.py @@ -391,6 +391,14 @@ class NetworkMgr(object): def dump_user(self, username): self.etcd.setkey("network/users/"+username, json.dumps({'info':self.users[username].info, 'vlanid':self.users[username].vlanid, 'gateway':self.users[username].gateway, 'pool':self.users[username].pool})) + def load_usrgw(self,username): + [status, data] = self.etcd.getkey("network/usergws/"+username) + if status: + self.usergws[username] = data + + def dump_usrgw(self, username): + self.etcd.setkey("network/usrgws/"+username, self.usrgws[username]) + def printpools(self): print ("
") self.center.printpool() @@ -439,11 +447,13 @@ class NetworkMgr(object): return [True, "Release VLAN ID success"] def has_usrgw(self, username): + self.load_usrgw(username) return username in self.usrgws.keys() def setup_usrgw(self, username, nodemgr, worker=None): if not self.has_user(username): return [False,"user doesn't exist."] + self.load_usrgw(username) if username in self.usrgws.keys(): return [False,"user's gateway has been set up."] self.load_user(username) @@ -452,10 +462,12 @@ class NetworkMgr(object): ip = nodemgr.rpc_to_ip(worker) logger.info("setup gateway for %s with %s and vlan=%s on %s" % (username, usrpools.get_gateway_cidr(), str(usrpools.vlanid), ip)) self.usrgws[username] = ip + self.dump_usrgw(username) worker.setup_gw('docklet-br', username, usrpools.get_gateway_cidr(), str(usrpools.vlanid)) else: logger.info("setup gateway for %s with %s and vlan=%s on master" % (username, usrpools.get_gateway_cidr(), str(usrpools.vlanid))) self.usrgws[username] = self.masterip + self.dump_usrgw(username) netcontrol.setup_gw('docklet-br', username, usrpools.get_gateway_cidr(), str(usrpools.vlanid)) self.dump_user(username) del self.users[username] @@ -493,6 +505,7 @@ class NetworkMgr(object): worker = nodemgr.ip_to_rpc(ip) worker.del_gw('docklet-br', username) del self.usrgws[username] + self.etcd.delkey("network/usrgws/"+username) return [True, 'delete user\' gateway success'] def del_user(self, username, isshared = False): @@ -511,6 +524,7 @@ class NetworkMgr(object): return [True, 'delete user success'] def check_usergw(self, username, nodemgr): + self.load_usrgw(username) if username not in self.usrgws.keys(): return [False, 'user does not exist.'] ip = self.usrgws[username] diff --git a/src/vclustermgr.py b/src/vclustermgr.py index 4fc64a0..06a24a0 100755 --- a/src/vclustermgr.py +++ b/src/vclustermgr.py @@ -120,6 +120,7 @@ class VclusterMgr(object): if not success: return [False, message] if i == 0: + self.networkmgr.load_usrgw(username) proxy_server_ip = self.networkmgr.usrgws[username] lxc_name = username + "-" + str(clusterid) + "-" + str(i) hostname = "host-"+str(i) @@ -391,7 +392,7 @@ class VclusterMgr(object): try: target = 'http://'+info['containers'][0]['ip'].split('/')[0]+":10000" worker = self.nodemgr.ip_to_rpc(info['proxy_server_ip']) - worker.set_route('/go/'+username+'/'+clustername, target) + worker.set_route('/'+info['proxy_server_ip']+'/go/'+username+'/'+clustername, target) except: return [False, "start cluster failed with setting proxy failed"] # recover containers of this cluster diff --git a/web/templates/monitor/history.html b/web/templates/monitor/history.html index 0c46530..e64abc6 100644 --- a/web/templates/monitor/history.html +++ b/web/templates/monitor/history.html @@ -61,7 +61,7 @@ {% endblock %} {% block script_src %} - +