2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 04:07:48 +00:00

Add ability to retrieve user expiry

This allows a common piece of XCC information to be
provided.

Change-Id: Ia1f3aaa04acbcf30ecd58b9e037e21c427145282
This commit is contained in:
Jarrod Johnson 2019-07-09 12:43:38 -04:00
parent 06cf9a89ee
commit c832f63883
4 changed files with 25 additions and 2 deletions

View File

@ -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):

View File

@ -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

View File

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

View File

@ -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