From 4097248917a527afdbb65eec2eafb478093c58c5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 9 Jul 2019 13:22:46 -0400 Subject: [PATCH] Add user expiration info to redfish Port forward the IPMI support. Change-Id: Ic0d211d003001c0b1ef2ce5b275c513dcf9034e8 --- pyghmi/redfish/command.py | 3 +++ pyghmi/redfish/oem/generic.py | 3 +++ pyghmi/redfish/oem/lenovo/xcc.py | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 8330fbf3..edf46b91 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -316,6 +316,7 @@ class Command(object): currid = accinfo.get('Id', None) if currname: names[currid] = {'name': currname, 'uid': currid, + 'expiration': self.oem.get_user_expiration(currid), 'access': { 'privilege_level': accinfo.get( 'RoleId', 'Unknown')}} @@ -333,6 +334,7 @@ class Command(object): accinfo = self._do_web_request(account['@odata.id']) currid = accinfo.get('Id', None) if str(currid) == str(uid): + accinfo['expiration'] = self.oem.get_user_expiration(uid) return account['@odata.id'], accinfo def get_user(self, uid): @@ -349,6 +351,7 @@ class Command(object): currid = accinfo.get('Id', None) if str(currid) == str(uid): return {'name': currname, 'uid': uid, + 'expiration': self.oem.get_user_expiration(uid), 'access': { 'privilege_level': accinfo.get( 'RoleId', 'Unknown')}} diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 6a0f1247..3a613efd 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -109,3 +109,6 @@ class OEMHandler(object): def apply_license(self, filename, progress=None): raise exc.UnsupportedFunctionality() + + def get_user_expiration(self, uid): + return None \ No newline at end of file diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index f2d7edab..30f981a4 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -749,3 +749,13 @@ class OEMHandler(generic.OEMHandler): self.wc.grab_json_response('/api/providers/imm_fod', {'FOD_LicenseKeyInstall': licpath}) return self.get_licenses() + + def get_user_expiration(self, uid): + userinfo = self.wc.grab_json_response('/api/dataset/imm_users') + for user in userinfo['items'][0]['users']: + if str(user['users_user_id']) == str(uid): + days = user['users_pass_left_days'] + if days == 366: + return 0 + else: + return days