From 04a9b89d15e6e3305a5d1ddc167e8c77aefb6356 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 12 Aug 2013 16:10:00 -0400 Subject: [PATCH] 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 --- pyghmi/ipmi/command.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index e81cd94d..e239cfa8 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -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):