From 1f2375035697e5fde84a78451715b01201df381f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 17 Jan 2023 15:11:12 -0500 Subject: [PATCH] Add affluent detection to confluent Affluent agent will now have an SSDP response. Add support for at least recognizing and presenting this in the discovery data. --- confluent_server/confluent/discovery/core.py | 3 +++ .../confluent/discovery/protocols/ssdp.py | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index f941a37f..ddbec819 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -116,6 +116,7 @@ nodehandlers = { 'pxe-client': pxeh, 'onie-switch': None, 'cumulus-switch': None, + 'affluent-switch': None, 'service:io-device.Lenovo:management-module': None, 'service:thinkagile-storage': cpstorage, 'service:lenovo-tsm': tsm, @@ -127,6 +128,7 @@ servicenames = { 'cumulus-switch': 'cumulus-switch', 'service:lenovo-smm': 'lenovo-smm', 'service:lenovo-smm2': 'lenovo-smm2', + 'affluent-switch': 'affluent-switch', 'lenovo-xcc': 'lenovo-xcc', 'service:management-hardware.IBM:integrated-management-module2': 'lenovo-imm2', 'service:io-device.Lenovo:management-module': 'lenovo-switch', @@ -140,6 +142,7 @@ servicebyname = { 'cumulus-switch': 'cumulus-switch', 'lenovo-smm': 'service:lenovo-smm', 'lenovo-smm2': 'service:lenovo-smm2', + 'affluent-switch': 'affluent-switch', 'lenovo-xcc': 'lenovo-xcc', 'lenovo-imm2': 'service:management-hardware.IBM:integrated-management-module2', 'lenovo-switch': 'service:io-device.Lenovo:management-module', diff --git a/confluent_server/confluent/discovery/protocols/ssdp.py b/confluent_server/confluent/discovery/protocols/ssdp.py index 5e6b8b1d..c0625758 100644 --- a/confluent_server/confluent/discovery/protocols/ssdp.py +++ b/confluent_server/confluent/discovery/protocols/ssdp.py @@ -58,7 +58,7 @@ smsg = ('M-SEARCH * HTTP/1.1\r\n' def active_scan(handler, protocol=None): known_peers = set([]) - for scanned in scan(['urn:dmtf-org:service:redfish-rest:1']): + for scanned in scan(['urn:dmtf-org:service:redfish-rest:1', 'urn::service:affluent']): for addr in scanned['addresses']: if addr in known_peers: break @@ -381,6 +381,24 @@ def _find_service(service, target): querypool = gp.GreenPool() pooltargs = [] for nid in peerdata: + if peerdata[nid].get('services', [None])[0] == 'urn::service:affluent:1': + peerdata[nid]['attributes'] = { + 'type': 'affluent-switch', + } + peerdata[nid]['services'] = ['affluent-switch'] + mya = peerdata[nid]['attributes'] + usn = peerdata[nid]['usn'] + idinfo = usn.split('::') + for idi in idinfo: + key, val = idi.split(':', 1) + if key == 'uuid': + peerdata[nid]['uuid'] = val + elif key == 'serial': + mya['enclosure-serial-number'] = [val] + elif key == 'model': + mya['enclosure-machinetype-model'] = [val] + yield peerdata[nid] + continue if '/redfish/v1/' not in peerdata[nid].get('urls', ()) and '/redfish/v1' not in peerdata[nid].get('urls', ()): continue if '/DeviceDescription.json' in peerdata[nid]['urls']: @@ -466,6 +484,10 @@ def _parse_ssdp(peer, rsp, peerdata): peerdatum['services'] = [value] elif value not in peerdatum['services']: peerdatum['services'].append(value) + elif header == 'USN': + peerdatum['usn'] = value + elif header == 'MODELNAME': + peerdatum['modelname'] = value