diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index bf81dccf..30a2da6f 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1765,13 +1765,17 @@ class Command(object): ipmi_msg (bool) privilege_level: (str)[callback, user, operatorm administrator, proprietary, no_access] + expiration: + None for 'unknown', 0 for no expiry, days to expire otherwise. """ if channel is None: channel = self.get_network_channel() name = self.get_user_name(uid) access = self.get_user_access(uid, channel) + self.oem_init() + expiration = self._oem.get_user_expiration(uid) data = {'name': name, 'uid': uid, 'channel': channel, - 'access': access['access']} + 'access': access['access'], 'expiration': expiration} return data def get_name_uids(self, name, channel=None): diff --git a/pyghmi/ipmi/oem/generic.py b/pyghmi/ipmi/oem/generic.py index 3a3a553a..8fae6b20 100644 --- a/pyghmi/ipmi/oem/generic.py +++ b/pyghmi/ipmi/oem/generic.py @@ -364,3 +364,6 @@ class OEMHandler(object): def apply_license(self, filename, progress=None): raise exc.UnsupportedFunctionality() + + def get_user_expiration(self, uid): + return None diff --git a/pyghmi/ipmi/oem/lenovo/handler.py b/pyghmi/ipmi/oem/lenovo/handler.py index c1d3a723..0d616319 100755 --- a/pyghmi/ipmi/oem/lenovo/handler.py +++ b/pyghmi/ipmi/oem/lenovo/handler.py @@ -980,7 +980,12 @@ class OEMHandler(generic.OEMHandler): if self.has_xcc: return self.immhandler.get_licenses() return super(OEMHandler, self).get_licenses() - + + def get_user_expiration(self, uid): + if self.has_xcc: + return self.immhandler.get_user_expiration(uid) + return None + def delete_license(self, name): if self.has_xcc: return self.immhandler.delete_license(name) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 258dc5ab..3cc47c0c 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1836,3 +1836,14 @@ class XCCClient(IMMClient): self.wc.grab_json_response('/api/providers/imm_fod', {'FOD_LicenseKeyInstall': licpath}) return self.get_licenses() + + def get_user_expiration(self, uid): + uid = uid - 1 + userinfo = self.wc.grab_json_response('/api/dataset/imm_users') + for user in userinfo['items'][0]['users']: + if user['users_user_id'] == uid: + days = user['users_pass_left_days'] + if days == 366: + return 0 + else: + return days \ No newline at end of file