2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 11:57:34 +00:00

Add user expiration info to redfish

Port forward the IPMI support.

Change-Id: Ic0d211d003001c0b1ef2ce5b275c513dcf9034e8
This commit is contained in:
Jarrod Johnson 2019-07-09 13:22:46 -04:00
parent c832f63883
commit 4097248917
3 changed files with 16 additions and 0 deletions

View File

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

View File

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

View File

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