From 21b3c89974b9befcad46fd22c6837d44dd9aa6f1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 3 Sep 2019 10:06:18 -0400 Subject: [PATCH] Improve redfish plugin errors and attrib handling Redfish plugin was not handling the various socket error behaviors correctly. Additionally, the attribschanged handler was failing to actually do anything, so commands would gladly reuse an old redfish object if it were working. --- .../plugins/hardwaremanagement/redfish.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index b58e2106..fb9bd19c 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -1,5 +1,5 @@ # Copyright 2014 IBM Corporation -# Copyright 2015-2018 Lenovo +# Copyright 2015-2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -169,6 +169,12 @@ class IpmiCommandWrapper(ipmicommand.Command): try: super(IpmiCommandWrapper, self).__init__(**kwargs) except socket.error as se: + if (hasattr(se, 'errno') + and se.errno in (errno.ENETUNREACH, errno.EHOSTUNREACH, errno.EADDRNOTAVAIL)): + if hasattr(se, 'strerror'): + raise exc.TargetEndpointUnreachable(se.strerror) + else: + raise exc.TargetEndpointUnreachable(str(se)) if isinstance(se, socket.timeout) or (len(se) > 1 and se[1] == 'EHOSTUNREACH'): raise exc.TargetEndpointUnreachable('timeout') raise @@ -183,10 +189,8 @@ class IpmiCommandWrapper(ipmicommand.Command): def _attribschanged(self, nodeattribs, configmanager, **kwargs): try: - self.ipmi_session._mark_broken() - except AttributeError: - # if ipmi_session doesn't already exist, - # then do nothing + del persistent_ipmicmds[(self.node, configmanager.tenant)] + except KeyError: pass def get_health(self): @@ -300,6 +304,11 @@ def perform_request(operator, node, element, try: return IpmiHandler(operator, node, element, configdata, inputdata, cfg, results, realop).handle_request() + except socket.error as se: + if hasattr(se, 'strerror'): + results.put(msg.ConfluentTargetTimeout(node, se.strerror)) + else: + results.put(msg.ConfluentTargetTimeout(node, str(se))) except pygexc.IpmiException as ipmiexc: excmsg = str(ipmiexc) if excmsg in ('Session no longer connected', 'timeout'): @@ -327,6 +336,8 @@ def perform_request(operator, node, element, traceback.print_exc() finally: results.put('Done') + if (node, cfg.tenant) in persistent_ipmicmds: + del persistent_ipmicmds[(node, cfg.tenant)] persistent_ipmicmds = {} @@ -1399,5 +1410,3 @@ def delete(nodes, element, configmanager, inputdata): element, type='ffdc') return perform_requests( 'delete', nodes, element, configmanager, inputdata, 'delete') - -