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