diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 3c453966..6f986c6d 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -635,18 +635,6 @@ def detected(info): eventlet.spawn_after(10, info['protocol'].fix_info, info, safe_detected) return - try: - snum = info['attributes']['enclosure-serial-number'][0].strip() - if snum: - info['serialnumber'] = snum - known_serials[info['serialnumber']] = info - except (KeyError, IndexError): - pass - try: - info['modelnumber'] = info['attributes']['enclosure-machinetype-model'][0] - known_services[service].add(info['modelnumber']) - except (KeyError, IndexError): - pass if info['hwaddr'] in known_info and 'addresses' in info: # we should tee these up for parsing when an enclosure comes up # also when switch config parameters change, should discard @@ -678,6 +666,22 @@ def detected(info): if handler: handler = handler.NodeHandler(info, cfg) handler.scan() + try: + if 'modelnumber' not in info: + info['modelnumber'] = info['attributes']['enclosure-machinetype-model'][0] + except (KeyError, IndexError): + pass + if 'modelnumber' in info: + known_services[service].add(info['modelnumber']) + try: + if 'serialnumber' not in info: + snum = info['attributes']['enclosure-serial-number'][0].strip() + if snum: + info['serialnumber'] = snum + except (KeyError, IndexError): + pass + if 'serialnumber' in info: + known_serials[info['serialnumber']] = info uuid = info.get('uuid', None) if uuid_is_valid(uuid): known_uuids[uuid][info['hwaddr']] = info @@ -1340,7 +1344,7 @@ def start_detection(): if rechecker is None: rechecktime = util.monotonic_time() + 900 rechecker = eventlet.spawn_after(900, _periodic_recheck, cfg) - eventlet.spawn_n(ssdp.snoop, None, None, ssdp, get_node_by_uuid_or_mac) + eventlet.spawn_n(ssdp.snoop, safe_detected, None, ssdp, get_node_by_uuid_or_mac) def stop_autosense(): for watcher in list(autosensors): diff --git a/confluent_server/confluent/discovery/handlers/xcc.py b/confluent_server/confluent/discovery/handlers/xcc.py index d482e84e..b65f5049 100644 --- a/confluent_server/confluent/discovery/handlers/xcc.py +++ b/confluent_server/confluent/discovery/handlers/xcc.py @@ -30,15 +30,6 @@ import struct getaddrinfo = eventlet.support.greendns.getaddrinfo -def fixup_uuid(uuidprop): - baduuid = ''.join(uuidprop.split()) - uuidprefix = (baduuid[:8], baduuid[8:12], baduuid[12:16]) - a = codecs.encode(struct.pack('Athena' in info: - data['services'] = ['service:thinkagile-storage'] + wc = webclient.SecureHTTPConnection(_get_svrip(data), 443, verifycallback=lambda x: True) + peerinfo = wc.grab_json_response(url) + if url == '/DeviceDescription.json': + try: + peerinfo = peerinfo[0] + myuuid = peerinfo['node-uuid'].lower() + if '-' not in myuuid: + myuuid = '-'.join([myuuid[:8], myuuid[8:12], myuuid[12:16], myuuid[16:20], myuuid[20:]]) + data['uuid'] = myuuid + data['attributes'] = peerinfo + data['services'] = ['service:management-hardware.Lenovo:lenovo-xclarity-controller'] + return data + except (IndexError, KeyError): + url = '/redfish/v1/' + peerinfo = wc.grab_json_response('/redfish/v1/') + if url == '/redfish/v1/': + if 'UUID' in peerinfo: + data['services'] = ['service:redfish-bmc'] + data['uuid'] = peerinfo['UUID'].lower() return data - except Exception: - pass return None - def _parse_ssdp(peer, rsp, peerdata): nid = peer[0] mac = None @@ -378,9 +411,11 @@ def _parse_ssdp(peer, rsp, peerdata): if not headline: continue header, _, value = headline.partition(b':') - header = header.strip() - value = value.strip() + header = header.strip().decode('utf8') + value = value.strip().decode('utf8') if header == 'AL' or header == 'LOCATION': + value = value[value.index('://')+3:] + value = value[value.index('/'):] if 'urls' not in peerdatum: peerdatum['urls'] = [value] elif value not in peerdatum['urls']: