From 256750366253b09ca1d4d1039b97ca7a0fb7d7e5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 3 Apr 2020 11:01:55 -0400 Subject: [PATCH] Handle both types of CP reply The CP storage may reply with one of two distinct forms. Recognize either and treat them the same. --- .../confluent/discovery/protocols/slp.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/confluent_server/confluent/discovery/protocols/slp.py b/confluent_server/confluent/discovery/protocols/slp.py index 2ff45a23..11fc0e54 100644 --- a/confluent_server/confluent/discovery/protocols/slp.py +++ b/confluent_server/confluent/discovery/protocols/slp.py @@ -493,11 +493,13 @@ def snoop(handler, protocol=None): _add_attributes(peerbymacaddress[mac]) peerbymacaddress[mac]['hwaddr'] = mac peerbymacaddress[mac]['protocol'] = protocol - if 'service:ipmi' in peerbymacaddress[mac]['services']: - if 'service:ipmi//Athena:623' in peerbymacaddress[mac].get('urls', ()): + for srvurl in peerbymacaddress[mac].get('urls', ()): + if len(srvurl) > 4: + srvurl = srvurl[:-3] + if srvurl.endswith('://Athena:'): peerbymacaddress[mac]['services'] = ['service:thinkagile-storage'] - else: - continue + if 'service:ipmi' in peerbymacaddress[mac]['services']: + continue if 'service:lightttpd' in peerbymacaddress[mac]['services']: currinf = peerbymacaddress[mac] curratt = currinf.get('attributes', {}) @@ -568,11 +570,13 @@ def scan(srvtypes=_slp_services, addresses=None, localonly=False): _grab_rsps((net, net4), rsps, 1, xidmap) # now to analyze and flesh out the responses for id in rsps: - if 'service:ipmi' in rsps[id]['services']: - if 'service:ipmi://Athena:623' in rsps[id].get('urls', ''): + for srvurl in rsps[id].get('urls', ()): + if len(srvurl) > 4: + srvurl = srvurl[:-3] + if srvurl.endswith('://Athena:'): rsps[id]['services'] = ['service:thinkagile-storage'] - else: - continue + if 'service:ipmi' in rsps[id]['services']: + continue if localonly: for addr in rsps[id]['addresses']: if 'fe80' in addr[0]: