From 929cd5b566be9d6f15415c9b5e76eddcaf0fb3ea Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 18 Nov 2019 09:14:08 -0500 Subject: [PATCH] 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 --- pyghmi/redfish/command.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index f38d0880..1ea7fdd5 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -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(