2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-14 19:57:47 +00:00

Avoid telling a server to enter existing power state

Some redfish implementations do not handle such a request
gracefully.  Avoid sending the command if the command allegedly
would have no effect.

Change-Id: I21b3ce18bb37747b71a67cbd0268d227ade6aad9
This commit is contained in:
Jarrod Johnson 2019-11-18 09:14:08 -05:00
parent 2311bc9f0b
commit 929cd5b566

View File

@ -496,6 +496,10 @@ class Command(object):
if powerstate == 'boot':
oldpowerstate = self.get_power()['powerstate']
powerstate = 'on' if oldpowerstate == 'off' else 'reset'
elif powerstate in ('on', 'off'):
oldpowerstate = self.get_power()['powerstate']
if oldpowerstate == powerstate:
return {'powerstate': powerstate}
reqpowerstate = powerstate
if powerstate not in powerstates:
raise exc.InvalidParameterValue(