diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 8b9d0a6ddf94da9f1ebc79db75d828a232a6ed6d..4636d131f1a47e105dc980450ef067436fd3b57c 100644 --- a/inventory_provider/config.py +++ b/inventory_provider/config.py @@ -111,6 +111,7 @@ CONFIG_SCHEMA = { 'gws-direct-interface': { 'type': 'object', 'properties': { + 'info': {'type': 'string'}, 'tag': {'type': 'string'}, 'counters': {'$ref': '#/definitions/gws-direct-counters'} }, diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index f4fa2897c37f676b7d89c049703998745b348ba7..c85e5af8a81759be732ec695416a4195ce1f3e69 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -309,7 +309,8 @@ GWS_DIRECT_DATA_SCHEMA = { 'type': 'array', 'items': {'$ref': '#/definitions/counter'}, 'minItems': 1 - } + }, + 'info': {'type': 'string'} }, 'required': [ 'nren', 'isp', 'hostname', 'tag', 'counters'], @@ -1003,7 +1004,7 @@ def gws_direct(): snmp_params['priv'] = host['priv'] for ifc in host['interfaces']: - yield { + ifc_data = { 'nren': nren_isp['nren'], 'isp': nren_isp['isp'], 'hostname': host['hostname'], @@ -1016,6 +1017,9 @@ def gws_direct(): } for k, v in ifc['counters'].items()] } + if 'info' in ifc: + ifc_data['info'] = ifc['info'] + yield ifc_data result = json.dumps(list(_interfaces())) diff --git a/test/data/gws-direct.json b/test/data/gws-direct.json index 3e399fc623f0ffa1481f8c90ed4075af08186918..c2232886f75f5274905fd5e367abb81cbb605f0d 100644 --- a/test/data/gws-direct.json +++ b/test/data/gws-direct.json @@ -264,6 +264,7 @@ "interfaces": [ { "tag": "a", + "info": "Some PSNC CenturyLink text, interface XX-9/9/9.123 #123", "counters": { "traffic_in": "1.3.6.1.2.1.31.1.1.1.6.675", "traffic_out": "1.3.6.1.2.1.31.1.1.1.10.675" @@ -304,6 +305,7 @@ "interfaces": [ { "tag": "a", + "info": "Some HEANET CenturyLink text", "counters": { "traffic_in": "1.3.6.1.2.1.31.1.1.1.6.645", "traffic_out": "1.3.6.1.2.1.31.1.1.1.10.645" diff --git a/test/test_general_poller_routes.py b/test/test_general_poller_routes.py index f9244bb5e6ef72d9a8225f83a868ecdc21004737..d04faa3b85cbb3d77d7dbf97bdb6a2ba7b8e4fad 100644 --- a/test/test_general_poller_routes.py +++ b/test/test_general_poller_routes.py @@ -76,7 +76,7 @@ def test_gws_direct(client): assert rv.is_json response_data = json.loads(rv.data.decode('utf-8')) jsonschema.validate(response_data, poller.GWS_DIRECT_DATA_SCHEMA) - assert response_data, "the subscription list shouldn't be empty" + assert response_data, "the service list shouldn't be empty" def test_gws_indirect(client):