recover usernet when recovering cluster
This commit is contained in:
parent
0b733b79f5
commit
eb7e5f826f
|
@ -182,6 +182,14 @@ class ovscontrol(object):
|
|||
except subprocess.CalledProcessError as suberror:
|
||||
return [False, "delete port failed : %s" % suberror.stdout.decode('utf-8')]
|
||||
|
||||
@staticmethod
|
||||
def add_port(bridge, port):
|
||||
try:
|
||||
subprocess.run(['ovs-vsctl', '--may-exist', 'add-port', str(bridge), str(port)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, check=True)
|
||||
return [True, str(port)]
|
||||
except subprocess.CalledProcessError as suberror:
|
||||
return [False, "add port failed : %s" % suberror.stdout.decode('utf-8')]
|
||||
|
||||
@staticmethod
|
||||
def add_port_internal(bridge, port):
|
||||
try:
|
||||
|
@ -281,5 +289,9 @@ class netcontrol(object):
|
|||
ipcontrol.up_link(gwport)
|
||||
return [True, "check gateway port %s" % gwport]
|
||||
|
||||
#@staticmethod
|
||||
#def check_usernet(uid, GatewayHost):
|
||||
@staticmethod
|
||||
def recover_usernet(portname, uid, GatewayHost, isGatewayHost):
|
||||
ovscontrol.add_bridge("docklet-br-"+str(uid))
|
||||
if not isGatewayHost:
|
||||
ovscontrol.add_port_vxlan("docklet-br-"+str(uid), "vxlan-"+str(uid)+"-"+GatewayHost, GatewayHost, str(uid))
|
||||
ovscontrol.add_port("docklet-br-"+str(uid), portname)
|
||||
|
|
|
@ -443,7 +443,9 @@ class VclusterMgr(object):
|
|||
if worker is None:
|
||||
return [False, "The worker can't be found or has been stopped."]
|
||||
worker.recover_container(container['containername'])
|
||||
#worker.check_usernet(uid, info['proxy_server_ip'])
|
||||
namesplit = container['containername'].split('-')
|
||||
portname = namesplit[1] + '-' + namesplit[2]
|
||||
worker.recover_usernet(portname, uid, info['proxy_server_ip'], container['host']==info['proxy_server_ip'])
|
||||
return [True, "start cluster"]
|
||||
|
||||
# maybe here should use cluster id
|
||||
|
|
|
@ -130,6 +130,7 @@ class Worker(object):
|
|||
self.rpcserver.register_function(netcontrol.del_bridge)
|
||||
self.rpcserver.register_function(ovscontrol.add_port_vxlan)
|
||||
self.rpcserver.register_function(netcontrol.check_gw)
|
||||
self.rpcserver.register_function(netcontrol.recover_usernet)
|
||||
self.rpcserver.register_function(proxytool.set_route)
|
||||
self.rpcserver.register_function(proxytool.delete_route)
|
||||
# register functions or instances to server for rpc
|
||||
|
|
Loading…
Reference in New Issue