diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 23384f920165dacf2b7d83fd705b03fd2c69ba1b..f6762d7dc3d55d12b57488dae844c1d143a1f137 100644 --- a/inventory_provider/config.py +++ b/inventory_provider/config.py @@ -184,11 +184,16 @@ CONFIG_SCHEMA = { 'items': {'$ref': '#/definitions/gws-direct-nren-isp'} }, 'nren-asn-map': { - 'type': 'object', - 'patternProperties': { - r'^\d+$': {'type': 'string'} + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'nren': {'type': 'string'}, + 'asn': {'type': 'integer'} + }, + 'required': ['nren', 'asn'], + 'additionalProperties': False }, - 'additionalProperties': False } }, diff --git a/inventory_provider/routes/msr.py b/inventory_provider/routes/msr.py index 6e251e56dc9eaca4b5243a082d6241e7e30f6c99..db0ad757efb3b00620278e1b4a7e7ea2c18ca253 100644 --- a/inventory_provider/routes/msr.py +++ b/inventory_provider/routes/msr.py @@ -1057,9 +1057,9 @@ def mdvpn(): config = current_app.config['INVENTORY_PROVIDER_CONFIG'] nren_asn_map = config['nren-asn-map'] nren_details = [ - _peerings_for_nren(int(asn), + _peerings_for_nren(pair['asn'], bgplu_index, vpnrr_index) - for asn in nren_asn_map] + for pair in nren_asn_map] response = json.dumps(nren_details) return Response(response, mimetype='application/json') diff --git a/test/conftest.py b/test/conftest.py index b54d49f586a540db0d4683c1b83cd1f322d649ff..af538eb3146301749989bc69d6fad04e327f7184 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -66,11 +66,20 @@ def data_config_filename(): } ], 'gws-direct': {}, - 'nren-asn-map': { - "1930": "FOO", - "680": "BAR", - "2200": "BAT" - } + 'nren-asn-map': [ + { + "nren": "FOO", + "asn": 1930 + }, + { + "nren": "BAR", + "asn": 680 + }, + { + "nren": "BAT", + "asn": 2200 + } + ] } with open(os.path.join(TEST_DATA_DIRNAME, 'gws-direct.json')) as gws: