From 0dbf82b0f1a56e918eb310674d3ad05712a8ed08 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 17 May 2018 16:24:06 -0400 Subject: [PATCH 1/4] Clean up errors on bad ipv4 addresses confluent errors are better now --- confluent_client/bin/nodeconfig | 4 ---- .../plugins/hardwaremanagement/ipmi.py | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/confluent_client/bin/nodeconfig b/confluent_client/bin/nodeconfig index 170fe335..e0f19885 100755 --- a/confluent_client/bin/nodeconfig +++ b/confluent_client/bin/nodeconfig @@ -191,10 +191,6 @@ if setmode: for node in fr.get('databynode', []): r = fr['databynode'][node] exitcode |= client.printerror(r, node) - if 'error' in r: - sys.stderr.write(node + ': ' + r['error'] + '\n') - if 'errorcode' in r: - rcode |= r['errorcode'] if 'value' not in r: continue keyval = r['value'] diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index ae93d8e9..e2e9ecd6 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -597,10 +597,20 @@ class IpmiHandler(object): )) elif self.op == 'update': config = self.inputdata.netconfig(self.node) - self.ipmicmd.set_net_configuration( - ipv4_address=config['ipv4_address'], - ipv4_configuration=config['ipv4_configuration'], - ipv4_gateway=config['ipv4_gateway']) + try: + self.ipmicmd.set_net_configuration( + ipv4_address=config['ipv4_address'], + ipv4_configuration=config['ipv4_configuration'], + ipv4_gateway=config['ipv4_gateway']) + except socket.error as se: + self.output.put(msg.ConfluentNodeError(self.node, + se.message)) + except ValueError as e: + if e.message == 'negative shift count': + self.output.put(msg.ConfluentNodeError( + self.node, 'Invalid prefix length given')) + else: + raise def handle_users(self): # Create user From 32d60145f7686c241a37dba99613b768035c0f96 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 18 May 2018 10:20:31 -0400 Subject: [PATCH 2/4] Fix typo in discovery core --- confluent_server/confluent/discovery/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index defb761a..8fc7d207 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -895,7 +895,7 @@ def eval_node(cfg, handler, info, nodename, manual=False): if enl: # ambiguous SMM situation according to the configuration, we need # to match uuid - encuuid = info['attributes'].get('chasis-uuid', None) + encuuid = info['attributes'].get('chassis-uuid', None) if encuuid: enl = list(cfg.filter_node_attributes('id.uuid=' + encuuid)) if len(enl) != 1: From fbbb5d048fb6c25cfe689d91601897f4fd8638dc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 18 May 2018 11:47:34 -0400 Subject: [PATCH 3/4] Fix the encuuid reference encuuid is a list, not the value, so get the first value rather than try to concatenate the string. --- confluent_server/confluent/discovery/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 8fc7d207..645d533c 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -897,6 +897,7 @@ def eval_node(cfg, handler, info, nodename, manual=False): # to match uuid encuuid = info['attributes'].get('chassis-uuid', None) if encuuid: + encuuid = encuuid[0] enl = list(cfg.filter_node_attributes('id.uuid=' + encuuid)) if len(enl) != 1: # errorstr = 'No SMM by given UUID known, *yet*' From a4fed0601ca63ed85ff9b87efd0e8d621e1c5cb2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 21 May 2018 15:53:12 -0400 Subject: [PATCH 4/4] Fix unprintable characters in some chassisid Some switches send raw octets back, some printable. Try to normalize when unprintable chassis id are detected. This is not 100%, if the hex would be all between 20 and 80 throughout the string, then this will fail to do the right thing. Hopefully, the amount of times when lldp partners disagree on how to implement LLDP-MIB will be limited. Currently it is known than Lenovo and Juniper switches disagree, and both of those have what would be unprintable values in the mfg portion of the chassis id. --- confluent_server/confluent/networking/lldp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/networking/lldp.py b/confluent_server/confluent/networking/lldp.py index 7641ccd7..e8fdc009 100644 --- a/confluent_server/confluent/networking/lldp.py +++ b/confluent_server/confluent/networking/lldp.py @@ -151,6 +151,9 @@ def _extract_extended_desc(info, source, integritychecked): info['peerdescription'] = source def sanitize(val): + # This is pretty much the same approach net-snmp takes. + # if the string is printable as-is, then just give it as-is + # if the string has non-printable, then hexify it val = str(val) for x in val.strip('\x00'): if ord(x) < 32 or ord(x) > 128: @@ -161,7 +164,7 @@ def sanitize(val): def _init_lldp(data, iname, idx, idxtoportid, switch): if iname not in data: data[iname] = {'port': iname, 'portid': str(idxtoportid[idx]), - 'chassisid': str(_chassisidbyswitch[switch])} + 'chassisid': _chassisidbyswitch[switch]} def _extract_neighbor_data_b(args): """Build LLDP data about elements connected to switch @@ -180,7 +183,8 @@ def _extract_neighbor_data_b(args): sid = str(sysid[1][6:]) idxtoifname = {} idxtoportid = {} - _chassisidbyswitch[switch] = list(conn.walk('1.0.8802.1.1.2.1.3.2'))[0][1] + _chassisidbyswitch[switch] = sanitize(list( + conn.walk('1.0.8802.1.1.2.1.3.2'))[0][1]) for oidindex in conn.walk('1.0.8802.1.1.2.1.3.7.1.3'): idx = oidindex[0][-1] idxtoportid[idx] = sanitize(oidindex[1])