replace vxlan with gre
This commit is contained in:
parent
f97e424268
commit
9651d05d47
|
@ -215,9 +215,9 @@ class ovscontrol(object):
|
|||
return [False, "add port failed : %s" % suberror.stdout.decode('utf-8')]
|
||||
|
||||
@staticmethod
|
||||
def add_port_vxlan(bridge, port, remote, key):
|
||||
def add_port_gre_withkey(bridge, port, remote, key):
|
||||
try:
|
||||
subprocess.run(['ovs-vsctl', '--may-exist', 'add-port', str(bridge), str(port), '--', 'set', 'interface', str(port), 'type=vxlan', 'options:remote_ip='+str(remote), 'options:key='+str(key)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, check=True)
|
||||
subprocess.run(['ovs-vsctl', '--may-exist', 'add-port', str(bridge), str(port), '--', 'set', 'interface', str(port), 'type=gre', 'options:remote_ip='+str(remote), 'options:key='+str(key)], 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')]
|
||||
|
@ -293,5 +293,5 @@ class netcontrol(object):
|
|||
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_gre_withkey("docklet-br-"+str(uid), "gre-"+str(uid)+"-"+GatewayHost, GatewayHost, str(uid))
|
||||
ovscontrol.add_port("docklet-br-"+str(uid), portname)
|
||||
|
|
|
@ -546,20 +546,20 @@ class NetworkMgr(object):
|
|||
del self.users[username]
|
||||
return [True, 'check gw ok']
|
||||
|
||||
def check_uservxlan(self, username, uid, remote, nodemgr, distributedgw=False):
|
||||
logger.info("Check %s(%s) vxlan from gateway host to %s." % (username, str(uid), remote))
|
||||
def check_usergre(self, username, uid, remote, nodemgr, distributedgw=False):
|
||||
logger.info("Check %s(%s) gre from gateway host to %s." % (username, str(uid), remote))
|
||||
self.load_usrgw(username)
|
||||
if username not in self.usrgws.keys():
|
||||
return [False, 'user does not exist.']
|
||||
ip = self.usrgws[username]
|
||||
if not distributedgw:
|
||||
if not remote == self.masterip:
|
||||
ovscontrol.add_port_vxlan('docklet-br-'+str(uid), 'vxlan-'+str(uid)+'-'+remote, remote, uid)
|
||||
ovscontrol.add_port_gre_withkey('docklet-br-'+str(uid), 'gre-'+str(uid)+'-'+remote, remote, uid)
|
||||
else:
|
||||
if not remote == ip:
|
||||
worker = nodemgr.ip_to_rpc(ip)
|
||||
worker.add_port_vxlan('docklet-br-'+str(uid), 'vxlan-'+str(uid)+'-'+remote, remote, uid)
|
||||
return [True, 'check vxlan ok']
|
||||
worker.add_port_gre_withkey('docklet-br-'+str(uid), 'gre-'+str(uid)+'-'+remote, remote, uid)
|
||||
return [True, 'check gre ok']
|
||||
|
||||
def has_user(self, username):
|
||||
[status, _value] = self.etcd.getkey("network/users/"+username)
|
||||
|
|
|
@ -431,8 +431,8 @@ class VclusterMgr(object):
|
|||
except:
|
||||
return [False, "start cluster failed with setting proxy failed"]
|
||||
for container in info['containers']:
|
||||
# set up vxlan from user's gateway host to container's host.
|
||||
self.networkmgr.check_uservxlan(username, uid, container['host'], self.nodemgr, self.distributedgw=='True')
|
||||
# set up gre from user's gateway host to container's host.
|
||||
self.networkmgr.check_usergre(username, uid, container['host'], self.nodemgr, self.distributedgw=='True')
|
||||
worker = xmlrpc.client.ServerProxy("http://%s:%s" % (container['host'], env.getenv("WORKER_PORT")))
|
||||
if worker is None:
|
||||
return [False, "The worker can't be found or has been stopped."]
|
||||
|
@ -492,8 +492,8 @@ class VclusterMgr(object):
|
|||
return [False, "start cluster failed with setting proxy failed"]
|
||||
# recover containers of this cluster
|
||||
for container in info['containers']:
|
||||
# set up vxlan from user's gateway host to container's host.
|
||||
self.networkmgr.check_uservxlan(username, uid, container['host'], self.nodemgr, self.distributedgw=='True')
|
||||
# set up gre from user's gateway host to container's host.
|
||||
self.networkmgr.check_usergre(username, uid, container['host'], self.nodemgr, self.distributedgw=='True')
|
||||
worker = xmlrpc.client.ServerProxy("http://%s:%s" % (container['host'], env.getenv("WORKER_PORT")))
|
||||
if worker is None:
|
||||
return [False, "The worker can't be found or has been stopped."]
|
||||
|
|
|
@ -128,7 +128,7 @@ class Worker(object):
|
|||
self.rpcserver.register_function(netcontrol.setup_gw)
|
||||
self.rpcserver.register_function(netcontrol.del_gw)
|
||||
self.rpcserver.register_function(netcontrol.del_bridge)
|
||||
self.rpcserver.register_function(ovscontrol.add_port_vxlan)
|
||||
self.rpcserver.register_function(ovscontrol.add_port_gre_withkey)
|
||||
self.rpcserver.register_function(netcontrol.check_gw)
|
||||
self.rpcserver.register_function(netcontrol.recover_usernet)
|
||||
self.rpcserver.register_function(proxytool.set_route)
|
||||
|
|
Loading…
Reference in New Issue