Commit 6e580290 authored by Simon Redman's avatar Simon Redman

Add endpoint for getting route information from controller nlsdn node

- I didn't actually end up using this, but I'll leave it here anyway
- Not tested at all
parent f7e12e85
......@@ -256,3 +256,27 @@ class North_api(ControllerBase):
json=ip_mapping,
headers=headers,
)
def get_routes_of_node(self, req):
"""
Return the result of asking for /service/nl/v1/routes
(Assumes an nlsdn ID)
:param req:
"""
body = json.loads(s=req.body.decode('utf-8'))
for required_key in ['dpid']:
if not required_key in body:
error = "Invalid POST; missing key {key}".format(key=required_key)
LOG.info(error)
return Response(status=422, headers=HEADERS, body=error)
dpid: int = int(body['dpid'])
routes = self.nlsdn_controller.get_routes(dpid)
return Response(status=200,
content_type='application/json',
json=routes,
headers=HEADERS,
)
......@@ -101,6 +101,11 @@ class SR_rest_api(app_manager.RyuApp):
controller=North_api, action='get_nlsdn_ids',
conditions=dict(method=['GET']))
uri = '/get-routes'
mapper.connect(flow_mgmt, uri,
controller=North_api, action='get_routes_of_node',
conditions=dict(method=['GET']))
uri = '/netjsonimport'
mapper.connect(flow_mgmt, uri,
controller=Te_controller, action='netjson_import',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment