From 24fd1e72e1e33fa7dbc2317c92b0c73b6f15d63d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 19 Nov 2018 14:39:56 -0500 Subject: [PATCH] Expose advertised, not valided IPs in discovery There are circumstances where the advertised IP is useful information, even if that IP cannot be validated. It is also the case that most of the time the advertised IP is useless if not validated, so it is an optional field. --- confluent_client/bin/nodediscover | 5 ++++- confluent_server/confluent/discovery/core.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index b6b485de..1d1d4c39 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -44,6 +44,8 @@ columnmapping = { 'Mac': 'macs', 'Switch': 'switch', 'Port': 'port', + 'Advertised IP': 'otheripaddrs', + 'Other IP': 'otheripaddrs', } @@ -208,7 +210,8 @@ def list_discovery(options, session): columns = [] for field in options.fields.split(','): for cdt in columnmapping: - if cdt.lower() == field.lower(): + if cdt.lower().replace( + ' ', '') == field.lower().replace(' ', ''): columns.append(cdt) else: columns = defcolumns diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 9f37f424..bb23e2e1 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -211,6 +211,8 @@ def send_discovery_datum(info): if infotype in servicenames: types.append(servicenames[infotype]) yield msg.KeyValueData({'types': types}) + if 'otheraddresses' in info: + yield msg.KeyValueData({'otheripaddrs': list(info['otheraddresses'])}) def _info_matches(info, criteria): @@ -637,6 +639,9 @@ def detected(info): uuid = info.get('uuid', None) if uuid_is_valid(uuid): known_uuids[uuid][info['hwaddr']] = info + info['otheraddresses'] = set([]) + for i4addr in info.get('attributes', {}).get('ipv4-address', []): + info['otheraddresses'].add(i4addr) if handler and handler.https_supported and not handler.https_cert: if handler.cert_fail_reason == 'unreachable': log.log(