mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 17:46:38 +00:00
Merge pull request #4888 from xuweibj/rpower_error
return code on error should be 1 instead of 0 ---rpower
This commit is contained in:
commit
1f93f8332d
@ -55,14 +55,11 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
obmc.login()
|
||||
states = obmc.list_power_states()
|
||||
state = self._determine_state(states)
|
||||
result = '%s: %s' % (node, openbmc.RPOWER_STATES.get(state, state))
|
||||
self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES.get(state, state)))
|
||||
|
||||
except SelfServerException as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
except SelfClientException as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
except (SelfServerException, SelfClientException) as e:
|
||||
self.callback.error(e.message, node)
|
||||
|
||||
self.callback.info(result)
|
||||
return state
|
||||
|
||||
def get_bmcstate(self, **kw):
|
||||
@ -86,13 +83,12 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
if bmc_state != 'Ready':
|
||||
bmc_state = bmc_not_ready
|
||||
|
||||
result = '%s: %s' % (node, openbmc.RPOWER_STATES.get(bmc_state, bmc_state))
|
||||
self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES.get(bmc_state, bmc_state)))
|
||||
|
||||
except SelfServerException, SelfClientException:
|
||||
# There is no response when BMC is not ready
|
||||
result = '%s: %s' % (node, openbmc.RPOWER_STATES[bmc_not_ready])
|
||||
self.callback.error(openbmc.RPOWER_STATES[bmc_not_ready], node)
|
||||
|
||||
self.callback.info(result)
|
||||
return bmc_state
|
||||
|
||||
def set_state(self, state, **kw):
|
||||
@ -105,14 +101,11 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
ret = obmc.set_power_state(state)
|
||||
new_status = POWER_STATE_DB.get(state, '')
|
||||
|
||||
result = '%s: %s' % (node, state)
|
||||
self.callback.info('%s: %s' % (node, state))
|
||||
if new_status:
|
||||
self.callback.update_node_attributes('status', node, new_status)
|
||||
except (SelfServerException, SelfClientException) as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
|
||||
self.callback.info(result)
|
||||
|
||||
self.callback.error(e.message, node)
|
||||
|
||||
def reboot(self, optype='boot', **kw):
|
||||
|
||||
@ -127,7 +120,7 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
new_status =''
|
||||
if optype == 'reset' and status in ['Off', 'chassison']:
|
||||
status = openbmc.RPOWER_STATES['Off']
|
||||
result = '%s: %s' % (node, status)
|
||||
self.callback.info('%s: %s' % (node, status))
|
||||
else:
|
||||
if status not in ['Off', 'off']:
|
||||
obmc.set_power_state('off')
|
||||
@ -153,13 +146,10 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
ret = obmc.set_power_state('on')
|
||||
self.callback.update_node_attributes('status', node, POWER_STATE_DB['on'])
|
||||
|
||||
result = '%s: %s' % (node, 'reset')
|
||||
self.callback.info('%s: %s' % (node, 'reset'))
|
||||
|
||||
except (SelfServerException, SelfClientException) as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
|
||||
self.callback.info(result)
|
||||
|
||||
self.callback.error(e.message, node)
|
||||
|
||||
def reboot_bmc(self, optype='warm', **kw):
|
||||
|
||||
@ -170,13 +160,12 @@ class OpenBMCPowerTask(ParallelNodesCommand):
|
||||
try:
|
||||
obmc.login()
|
||||
except (SelfServerException, SelfClientException) as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
self.callback.error(e.message, node)
|
||||
else:
|
||||
try:
|
||||
obmc.reboot_bmc(optype)
|
||||
except (SelfServerException, SelfClientException) as e:
|
||||
result = '%s: %s' % (node, e.message)
|
||||
self.callback.error(e.message, node)
|
||||
else:
|
||||
result = '%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot'])
|
||||
self.callback.info(result)
|
||||
self.callback.info('%s: %s' % (node, openbmc.RPOWER_STATES['bmcreboot']))
|
||||
|
||||
|
@ -305,7 +305,7 @@ class OpenBMCRest(object):
|
||||
|
||||
self._log_request(method, url, httpheaders, data=data, cmd=cmd)
|
||||
try:
|
||||
response = self.session.request(method, url, httpheaders, data=data)
|
||||
response = self.session.request(method, url, httpheaders, data=data, timeout=timeout)
|
||||
return self.handle_response(response, cmd=cmd)
|
||||
except SelfServerException as e:
|
||||
e.message = 'Error: BMC did not respond. ' \
|
||||
|
@ -703,7 +703,7 @@ my %allerrornodes = ();
|
||||
|
||||
my $xcatdebugmode = 0;
|
||||
|
||||
my $flag_debug = "[openbmc_debug]";
|
||||
my $flag_debug = "[openbmc_debug_perl]";
|
||||
|
||||
my %login_pid_node; # used in process_request, record login fork pid map
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user