diff --git a/inventory_provider/routes/msr.py b/inventory_provider/routes/msr.py index 95887f10015a6ee23f467616bf5524e5dd9d4312..6f5087b2fdf6ff14fa2ddd40c298a0ba140c2733 100644 --- a/inventory_provider/routes/msr.py +++ b/inventory_provider/routes/msr.py @@ -54,6 +54,11 @@ These endpoints are intended for use by MSR. .. autofunction:: inventory_provider.routes.msr.bgp_routing_instance_peerings +/msr/bgp +-------------------------------------------- + +.. autofunction:: inventory_provider.routes.msr.bgp_all_peerings + /msr/services -------------------------------------------- @@ -849,3 +854,24 @@ def get_system_correlation_services(): mimetype="text/html") return Response(response, mimetype="application/json") + + +@routes.route('/bgp', methods=['GET', 'POST']) +@common.require_accepts_json +def bgp_all_peerings(): + """ + Handler for `/bgp` + + This method returns a list of all BGP peerigns. + + The response will be formatted according to the following schema: + + .. asjson:: + inventory_provider.routes.msr.PEERING_LIST_SCHEMA + + :return: + """ + + r = common.get_current_redis() + response = r.get('juniper-peerings:all') + return Response(response.decode('utf-8'), mimetype="application/json") diff --git a/test/data/router-info.json b/test/data/router-info.json index 213f34b48238c27b9d813ccddb8c914280e64405..9c7f8fae60f683657157596af5f7d128e7f0aaad 100644 Binary files a/test/data/router-info.json and b/test/data/router-info.json differ diff --git a/test/test_msr_routes.py b/test/test_msr_routes.py index 198864e68ae6613815f037bd8b8673e64fc1166d..0bec3d504185fa7070f8e06fa5a3686ec91c6c74 100644 --- a/test/test_msr_routes.py +++ b/test/test_msr_routes.py @@ -310,3 +310,14 @@ def test_system_correlation_services(client): response_data = json.loads(rv.data.decode('utf-8')) jsonschema.validate(response_data, SYSTEM_CORRELATION_SERVICES_LIST_SCHEMA) assert response_data # test data is non-empty + + +def test_get_all_peerings(client): + rv = client.get( + '/msr/bgp', + headers=DEFAULT_REQUEST_HEADERS) + assert rv.status_code == 200 + assert rv.is_json + response_data = json.loads(rv.data.decode('utf-8')) + jsonschema.validate(response_data, PEERING_LIST_SCHEMA) + assert response_data # test data is non-empty