From b7af6b5c27f9543d1d2af82957f159514580eed9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 22 Apr 2021 13:38:30 -0400 Subject: [PATCH] Add model name to discovery info Sometimes the model name is useful criteria for evaluating systems, and the model number isn't quite that handy. For XCC, we can provide this data too. Provide it in xcc scan method and then offer it up to clients. --- confluent_client/bin/nodediscover | 1 + confluent_server/confluent/discovery/core.py | 2 ++ confluent_server/confluent/discovery/handlers/xcc.py | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index 8a6e5877..84daa06d 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -34,6 +34,7 @@ defcolumns = ['Node', 'Model', 'Serial', 'UUID', 'Mac Address', 'Type', columnmapping = { 'Node': 'nodename', 'Model': 'modelnumber', + 'Model Name': 'modelname', 'Serial': 'serialnumber', 'UUID': 'uuid', 'Type': 'types', diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 4375a875..34fc39e4 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -252,6 +252,8 @@ def send_discovery_datum(info): yield msg.KeyValueData({'lowest_u': info['u']}) if 'hostname' in info: yield msg.KeyValueData({'hostname': info['hostname']}) + if 'modelname' in info: + yield msg.KeyValueData({'modelname': info['modelname']}) def _info_matches(info, criteria): diff --git a/confluent_server/confluent/discovery/handlers/xcc.py b/confluent_server/confluent/discovery/handlers/xcc.py index 8b868c8a..626d3b11 100644 --- a/confluent_server/confluent/discovery/handlers/xcc.py +++ b/confluent_server/confluent/discovery/handlers/xcc.py @@ -63,6 +63,14 @@ class NodeHandler(immhandler.NodeHandler): # This is not adequate for being satisfied return bool(info.get('attributes', {})) + def scan(self): + c = webclient.SecureHTTPConnection(self.ipaddr, 443, + verifycallback=self.validate_cert) + i = c.grab_json_response('/api/providers/logoninfo') + modelname = i.get('items', [{}])[0].get('machine_name', None) + if modelname: + self.info['modelname'] = modelname + def preconfig(self, possiblenode): self.tmpnodename = possiblenode ff = self.info.get('attributes', {}).get('enclosure-form-factor', '')