Broken routes

pull/8/head
Jack O'Sullivan 5 years ago
parent b5844947e4
commit 04f93b16cc

@ -181,17 +181,42 @@ def delete_endpoint():
@app.route('/NetworkDriver.Join', methods=['POST']) @app.route('/NetworkDriver.Join', methods=['POST'])
def join(): def join():
req = request.get_json(force=True) req = request.get_json(force=True)
logger.info(req)
bridge = net_bridge(req['NetworkID']) bridge = net_bridge(req['NetworkID'])
_if_host, if_container = veth_pair(req['EndpointID']) _if_host, if_container = veth_pair(req['EndpointID'])
return jsonify({ res = {
'InterfaceName': { 'InterfaceName': {
'SrcName': if_container, 'SrcName': if_container,
'DstPrefix': bridge.ifname 'DstPrefix': bridge.ifname
} },
}) 'StaticRoutes': []
}
# TODO: IPv6 routes
nonlink = []
for route in ipdb.routes:
logging.info(route)
if route.oif != bridge.index:
continue
if route.dst == 'default' and 'Gateway' not in res:
res['Gateway'] = route.gateway
elif route.gateway:
nonlink.append({
'Destination': route.dst,
'RouteType': 0,
'NextHop': route.gateway
})
else:
# on-link route
res['StaticRoutes'].append({
'Destination': route.dst,
'RouteType': 1
})
# we need to add the on-link routes first
res['StaticRoutes'] += nonlink
logger.info(res)
return jsonify(res)
@app.route('/NetworkDriver.Leave', methods=['POST']) @app.route('/NetworkDriver.Leave', methods=['POST'])
def leave(): def leave():

Loading…
Cancel
Save