From 13710aaa3720af0d1c0ae7a5b8ec025878d609da Mon Sep 17 00:00:00 2001 From: Erik Reid <erik.reid@geant.org> Date: Mon, 23 Aug 2021 13:36:44 +0200 Subject: [PATCH] added optional info field to gws direct input & output config schema --- inventory_provider/config.py | 1 + inventory_provider/routes/poller.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/inventory_provider/config.py b/inventory_provider/config.py index 8b9d0a6d..4636d131 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 f4fa2897..da22e402 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,8 @@ def gws_direct(): } for k, v in ifc['counters'].items()] } + if 'info' in ifc: + ifc_data['info'] = ifc['info'] result = json.dumps(list(_interfaces())) -- GitLab