From 86eaf594e60c43c1c39b5996dd65bca410d5a6ea Mon Sep 17 00:00:00 2001 From: xuweibj Date: Thu, 30 Aug 2018 02:45:40 -0400 Subject: [PATCH] retry in rpower reset when get 'Connection aborted' --- .../agent/hwctl/executor/openbmc_power.py | 27 +++++++++++++------ .../lib/python/agent/hwctl/openbmc_client.py | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py index 819fbc887..b6bc0b4e4 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_power.py @@ -109,12 +109,15 @@ class OpenBMCPowerTask(ParallelNodesCommand): off_flag = False start_timeStamp = int(time.time()) for i in range (0, 30): - states = obmc.list_power_states() - status = obmc.get_host_state(states) - if openbmc.RPOWER_STATES.get(status) == 'off': - off_flag = True - break gevent.sleep( 2 ) + try: + states = obmc.list_power_states() + status = obmc.get_host_state(states) + if openbmc.RPOWER_STATES.get(status) == 'off': + off_flag = True + break + except SelfServerException as e: + continue end_timeStamp = int(time.time()) @@ -123,10 +126,18 @@ class OpenBMCPowerTask(ParallelNodesCommand): 'to off after waiting %s seconds. (State= %s).' % (end_timeStamp - start_timeStamp, status) raise SelfServerException(error) - ret = obmc.set_power_state('on') - self.callback.update_node_attributes('status', node, POWER_STATE_DB['on']) + for i in range(0, 2): + try: + ret = obmc.set_power_state('on') + self.callback.update_node_attributes('status', node, POWER_STATE_DB['on']) + self.callback.info('%s: %s' % (node, 'reset')) + return + except SelfServerException as e: + self.callback.syslog('%s: %s' % (node, e.message)) + gevent.sleep( 1 ) + continue - self.callback.info('%s: %s' % (node, 'reset')) + self.callback.error(e.message, node) except (SelfServerException, SelfClientException) as e: self.callback.error(e.message, node) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py index 1670a51da..32f081d06 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py @@ -345,7 +345,7 @@ class OpenBMCRest(object): e.message = "Login to BMC failed: Can't connect to {0} {1}.".format(e.host_and_port, e.detail_msg) else: e.message = 'BMC did not respond. ' \ - 'Validate BMC configuration and retry the command.' + 'Validate BMC configuration and retry the command. ' + e.detail_msg self._print_error_log(e.message, cmd) raise except ValueError: