check_gw by rpc

This commit is contained in:
zhuyj17 2017-03-13 21:53:32 +08:00
parent e52d124e65
commit 76f87d669b
3 changed files with 12 additions and 4 deletions

View File

@ -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']

View File

@ -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"

View File

@ -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)