From 3799dd3f9b7ecba1d5dbf1fe6ad9c37dcbb9b4f9 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 29 Jan 2020 10:51:45 -0500 Subject: [PATCH] Change API for extended BMC configuration Keep extended configuration utterly separate to ease confusion by calling code as to what belongs to which category. Change-Id: Ic97ad79fa796f63b8825db48059450a4c78f75c9 --- pyghmi/ipmi/command.py | 8 ++++++-- pyghmi/ipmi/oem/generic.py | 14 +++++++++----- pyghmi/ipmi/oem/lenovo/handler.py | 11 ++++++++--- pyghmi/ipmi/oem/lenovo/imm.py | 14 ++++++++------ 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 746c7227..d886258d 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -776,9 +776,13 @@ class Command(object): else: raise Exception("Unrecognized data format " + repr(fetchdata)) - def get_bmc_configuration(self, extended=False): + def get_extended_bmc_configuration(self): self.oem_init() - return self._oem.get_bmc_configuration(extended) + return self._oem.get_extended_bmc_configuration() + + def get_bmc_configuration(self): + self.oem_init() + return self._oem.get_bmc_configuration() def set_bmc_configuration(self, changeset): self.oem_init() diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index fa5df146..0a0966a2 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -331,15 +331,19 @@ class OEMHandler(object): """ return False + def get_extended_bmc_configuration(self): + """Get extended bmc configuration + + In the case of potentially redundant/slow + attributes, retrieve unpopular options that may be + redundant or confusing and slow. + """ + return {} + def get_bmc_configuration(self, extended): """Get additional BMC parameters This allows a bmc to return arbitrary key-value pairs. - - :param extended: In the case of potentially redundant/slow - attributes, this allows the caller to opt - into retrieving unpopular options that may be - redundant or confusing. """ return {} diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 5fed6197..748f4f4e 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -969,12 +969,17 @@ class OEMHandler(generic.OEMHandler): return {'height': self._fpc_variant, 'slot': 0} return super(OEMHandler, self).get_description() - def get_bmc_configuration(self, extended): + def get_extended_bmc_configuration(self): if self.has_xcc: - return self.immhandler.get_bmc_configuration(extended) + return self.immhandler.get_extended_bmc_configuration() + return super(OEMHandler, self).get_extended_bmc_configuration() + + def get_bmc_configuration(self): + if self.has_xcc: + return self.immhandler.get_bmc_configuration() if self.is_fpc: return self.smmhandler.get_bmc_configuration() - return super(OEMHandler, self).get_bmc_configuration(extended) + return super(OEMHandler, self).get_bmc_configuration() def set_bmc_configuration(self, changeset): if self.has_xcc: diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 438291b3..382c7253 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -842,7 +842,14 @@ class XCCClient(IMMClient): return {} return {'height': int(dsc['u-height']), 'slot': int(dsc['slot'])} - def get_bmc_configuration(self, extended): + def get_extended_bmc_configuration(self): + immsettings = self.get_system_configuration(fetchimm=True) + for setting in immsettings: + if not setting.startswith('IMM.'): + del immsettings[setting] + return immsettings + + def get_bmc_configuration(self): settings = {} passrules = self.wc.grab_json_response('/api/dataset/imm_users_global') passrules = passrules.get('items', [{}])[0] @@ -876,11 +883,6 @@ class XCCClient(IMMClient): settings['smm']['value'] = 'Enable' else: settings['smm']['value'] = None - if extended: - immsettings = self.get_system_configuration(fetchimm=True) - for setting in immsettings: - if setting.startswith('IMM.'): - settings[setting] = immsettings[setting] return settings rulemap = {