mirror of
https://opendev.org/x/pyghmi
synced 2025-01-14 19:57:47 +00:00
Rework set_power handling of errors and noops
set_power failed to raise when error encountered. The behavior is amended to be consistent with other functions. set_power requested on/off state even if system already was in requested state. Change to simply report success in that scenario. Change-Id: I6feb8f4384705136a5ab1fae0899ea27b2d3511c
This commit is contained in:
parent
7e4f5a381f
commit
04a9b89d15
@ -152,14 +152,16 @@ class Command(object):
|
||||
self.newpowerstate = powerstate
|
||||
response = self.ipmi_session.raw_command(netfn=0, command=1)
|
||||
if 'error' in response:
|
||||
return response
|
||||
raise Exception(response['error'])
|
||||
self.powerstate = 'on' if (response['data'][0] & 1) else 'off'
|
||||
if self.powerstate == self.newpowerstate:
|
||||
return {'powerstate': self.powerstate}
|
||||
if self.newpowerstate == 'boot':
|
||||
self.newpowerstate = 'on' if self.powerstate == 'off' else 'reset'
|
||||
response = self.ipmi_session.raw_command(
|
||||
netfn=0, command=2, data=[power_states[self.newpowerstate]])
|
||||
if 'error' in response:
|
||||
return response
|
||||
raise Exception(response['error'])
|
||||
self.lastresponse = {'pendingpowerstate': self.newpowerstate}
|
||||
waitattempts = 300
|
||||
if not isinstance(wait, bool):
|
||||
|
Loading…
x
Reference in New Issue
Block a user