From cad67cf751c7c3d0f16d1a459fad7163e13f8f31 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 14 Jan 2019 11:21:59 -0500 Subject: [PATCH] Add support for XCC License key management XCC features are managed in keys, support management of those keys. Change-Id: I10a1e55dd6705cebacb8c49c98f19491bdf9e2d0 --- pyghmi/ipmi/command.py | 8 ++++++++ pyghmi/ipmi/oem/generic.py | 6 ++++++ pyghmi/ipmi/oem/lenovo/handler.py | 10 ++++++++++ pyghmi/ipmi/oem/lenovo/imm.py | 17 +++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 5388391d..956139a3 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1982,3 +1982,11 @@ class Command(object): """ self.oem_init() return self._oem.list_media() + + def get_licenses(self): + self.oem_init() + return self._oem.get_licenses() + + def apply_license(self, filename, progress=None): + self.oem_init() + return self._oem.apply_license(filename, progress) diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 4451e1c3..e4ad26c7 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -348,3 +348,9 @@ class OEMHandler(object): Takes a key value pair and applies it against the system configuration """ raise exc.UnsupportedFunctionality() + + def get_licenses(self): + raise exc.UnsupportedFunctionality() + + def apply_license(self, filename, progress=None): + raise exc.UnsupportedFunctionality() diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index 160916df..af115dcb 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -968,3 +968,13 @@ class OEMHandler(generic.OEMHandler): if self.has_xcc: return self.immhandler.get_health(summary) return super(OEMHandler, self).get_health(summary) + + def get_licenses(self): + if self.has_xcc: + return self.immhandler.get_licenses() + return super(OEMHandler, self).get_licenses() + + def apply_license(self, filename, progress=None): + if self.has_xcc: + return self.immhandler.apply_license(filename, progress) + return super(OEMHandler, self).apply_license(filename, progress) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index e6e69a59..f0c09b56 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1604,3 +1604,20 @@ class XCCClient(IMMClient): # The XCC reports healthy, no need to interrogate raise pygexc.BypassGenericBehavior() # Will use the generic handling for unhealthy systems + + def get_licenses(self): + licdata = self.wc.grab_json_response('/api/providers/imm_fod') + for lic in licdata.get('items', [{}])[0].get('keys', []): + if lic['status'] == 0: + yield {'name': lic['feature']} + + def apply_license(self, filename, progress=None): + uploadthread = webclient.FileUploader(self.wc, '/upload', filename) + uploadthread.start() + uploadthread.join() + rsp = json.loads(uploadthread.rsp) + licpath = rsp.get('items', [{}])[0].get('path', None) + if licpath: + self.wc.grab_json_response('/api/providers/imm_fod', + {'FOD_LicenseKeyInstall': licpath}) + return self.get_licenses()