diff --git a/src/network.py b/src/network.py index 9ae409c..b03cf23 100755 --- a/src/network.py +++ b/src/network.py @@ -509,9 +509,16 @@ class NetworkMgr(object): del self.users[username] return [True, 'delete user success'] - def check_usergw(self, username): + def check_usergw(self, username, nodemgr): + if username not in self.usrgws.keys(): + return [False, 'user does not exist.'] + ip = self.usrgws[username] self.load_user(username) - netcontrol.check_gw('docklet-br', username, self.users[username].get_gateway_cidr(), str(self.users[username].vlanid)) + if ip == 'm': + netcontrol.check_gw('docklet-br', username, self.users[username].get_gateway_cidr(), str(self.users[username].vlanid)) + else: + worker = nodemgr.ip_to_rpc(ip) + worker.check_gw('docklet-br', username, self.users[username].get_gateway_cidr(), str(self.users[username].vlanid)) del self.users[username] return [True, 'check gw ok'] diff --git a/src/vclustermgr.py b/src/vclustermgr.py index 983553d..99b3978 100755 --- a/src/vclustermgr.py +++ b/src/vclustermgr.py @@ -344,7 +344,7 @@ class VclusterMgr(object): # check gateway for user # after reboot, user gateway goes down and lose its configuration # so, check is necessary - self.networkmgr.check_usergw(username) + self.networkmgr.check_usergw(username, self.nodemgr) # set proxy try: target = 'http://'+info['containers'][0]['ip'].split('/')[0]+":10000" @@ -378,7 +378,7 @@ class VclusterMgr(object): if info['status'] == 'stopped': return [True, "cluster no need to start"] # need to check and recover gateway of this user - self.networkmgr.check_usergw(username) + self.networkmgr.check_usergw(username, self.nodemgr) # recover proxy of cluster try: target = 'http://'+info['containers'][0]['ip'].split('/')[0]+":10000" diff --git a/src/worker.py b/src/worker.py index c3a343e..0f472bb 100755 --- a/src/worker.py +++ b/src/worker.py @@ -127,6 +127,7 @@ class Worker(object): self.rpcserver.register_function(monitor.workerFetchInfo) self.rpcserver.register_function(netcontrol.setup_gw) self.rpcserver.register_function(netcontrol.del_gw) + self.rpcserver.register_function(netcontrol.check_gw) # register functions or instances to server for rpc #self.rpcserver.register_function(function_name)