From cf1016bf6acbfb06a8516376df317bf99a7b60cd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 22 Aug 2018 16:26:39 -0400 Subject: [PATCH] Provide get_description for physical description This function will enable GUI providers to have at least some generic information. Change-Id: Ic149ee23698c1c7c870b54b03355b8b8d87bd5f2 --- pyghmi/ipmi/command.py | 10 ++++++++++ pyghmi/ipmi/oem/generic.py | 10 ++++++++++ pyghmi/ipmi/oem/lenovo/handler.py | 5 +++++ pyghmi/ipmi/oem/lenovo/imm.py | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 6e26641a..02180fe4 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -417,6 +417,16 @@ class Command(object): rsp['data'] = buffer(rsp['data']) return rsp + def get_description(self): + """Get physical attributes for the system, e.g. for GUI use + + :returns: dict -- dict containing attributes, 'height' is for + how many U tall, 'slot' for what slot in a blade enclosure + or 0 if not blade, for example. + """ + self.oem_init() + return self._oem.get_description() + def raw_command(self, netfn, command, bridge_request=(), data=(), delay_xmit=None, retry=True, timeout=None): """Send raw ipmi command to BMC diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 2b2e2cb2..17270697 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -32,6 +32,16 @@ class OEMHandler(object): def get_video_launchdata(self): return {} + def get_description(self): + """Get a description of descriptive attributes of a node. + + Height describes, in U how tall the system is, and slot is 0 if + not a blade type server, and slot if it is. + + :return: dictionary with 'height' and 'slot' members + """ + return {} + def process_event(self, event, ipmicmd, seldata): """Modify an event according with OEM understanding. diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 5cafceed..ca5736bf 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -914,6 +914,11 @@ class OEMHandler(generic.OEMHandler): progress=progress, bank=bank) + def get_description(self): + if self.has_xcc: + return self.immhandler.get_description() + return super(OEMHandler, self).get_description() + def get_system_configuration(self, hideadvanced): if self.has_imm or self.has_xcc: return self.immhandler.get_system_configuration(hideadvanced) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index da69a457..ba5b1077 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -679,6 +679,11 @@ class XCCClient(IMMClient): super(XCCClient, self).__init__(ipmicmd) self.adp_referer = None + def get_description(self): + dsc = self.wc.grab_json_response('/DeviceDescription.json') + dsc = dsc[0] + return {'height': int(dsc['u-height']), 'slot': int(dsc['slot'])} + def get_webclient(self, login=True): cv = self.ipmicmd.certverify wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)