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):