From 467c2e52b890e0127d66c05bef0117d8b34dab3a Mon Sep 17 00:00:00 2001 From: Jarrod Johnon Date: Tue, 25 Nov 2014 11:26:27 -0500 Subject: [PATCH] Provide access to chassis identify Enable command method to turn on identify with full access to duration and indefinite control. Note that there is no method to retrieve it, as the specification does not provide that capability. Change-Id: I3478101ed4db15232842b508a42aeb9ec9285434 --- pyghmi/ipmi/command.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 1283722d..628cb47f 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -300,6 +300,39 @@ class Command(object): powerstate = 'on' if (response['data'][0] & 1) else 'off' return {'powerstate': powerstate} + def set_identify(self, on=True, duration=None): + """Request identify light + + Request the identify light to turn off, on for a duration, + or on indefinitely. Other than error exceptions, + + :param on: Set to True to force on or False to force off + :param duration: Set if wanting to request turn on for a duration + rather than indefinitely on + """ + if duration is not None: + duration = int(duration) + if duration > 255: + duration = 255 + if duration < 0: + duration = 0 + response = self.raw_command(netfn=0, command=4, data=[duration]) + if 'error' in response: + raise exc.IpmiException(response['error']) + return + forceon = 0 + if on: + forceon = 1 + if self.ipmi_session.ipmiversion < 2.0: + # ipmi 1.5 made due with just one byte, make best effort + # to imitate indefinite as close as possible + identifydata = [255 * forceon] + else: + identifydata = [0, forceon] + response = self.raw_command(netfn=0, command=4, data=identifydata) + if 'error' in response: + raise exc.IpmiException(response['error']) + def get_health(self): """Summarize health of managed system