diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 1ecf913c..57c8e90e 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1260,6 +1260,13 @@ class Command(object): def get_diagnostic_data(self, savefile, progress=None): return self.oem.get_diagnostic_data(savefile, progress) + def get_licenses(self): + return self.oem.get_licenses() + + def apply_license(self, filename, progress=None): + return self.oem.apply_license(filename, progress) + + if __name__ == '__main__': import os import sys diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 2a2822e8..9fd15c75 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -87,4 +87,10 @@ class OEMHandler(object): :return: """ raise exc.UnsupportedFunctionality( - 'Do not know how to get diagnostic data for this platform') \ No newline at end of file + 'Do not know how to get diagnostic data for this platform') + + def get_licenses(self): + raise exc.UnsupportedFunctionality() + + def apply_license(self, filename, progress=None): + raise exc.UnsupportedFunctionality() diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 3ab17760..2f7d3fbd 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -702,4 +702,21 @@ class OEMHandler(generic.OEMHandler): 'progress': 100 * self.wc.get_download_progress()}) self._refresh_token() if progress: - progress({'phase': 'complete'}) \ No newline at end of file + progress({'phase': 'complete'}) + + 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()