mirror of
https://opendev.org/x/pyghmi
synced 2026-10-06 17:46:59 +00:00
Attempt better redfish account deletion
Better redfish implementations offer the sane option of just deleting the account, try that before trying to hack our way out of a bad implementation. Change-Id: Icb97a0ae18bdafd3fed3528f5eee6ed6ba40cdac
This commit is contained in:
@@ -445,7 +445,7 @@ class Command(object):
|
||||
return self.oem.get_ikvm_launchdata()
|
||||
|
||||
def user_delete(self, uid):
|
||||
self.oem.user_delete(uid)
|
||||
self.oem.user_delete(uid, self)
|
||||
|
||||
def set_user_name(self, uid, name):
|
||||
"""Set user name
|
||||
|
||||
@@ -383,13 +383,19 @@ class OEMHandler(object):
|
||||
summary['badreadings'].append(unkinf)
|
||||
return summary
|
||||
|
||||
def user_delete(self, uid):
|
||||
def user_delete(self, uid, fishclient):
|
||||
# Redfish doesn't do so well with Deleting users either...
|
||||
# Blanking the username seems to be the convention
|
||||
# First, set a bogus password in case the implementation does honor
|
||||
# blank user, at least render such an account harmless
|
||||
self.set_user_password(uid, base64.b64encode(os.urandom(15)))
|
||||
self.set_user_name(uid, '')
|
||||
try:
|
||||
accinfo = fishclient._account_url_info_by_id(uid)
|
||||
if not accinfo:
|
||||
raise Exception("No such account found")
|
||||
self._do_web_request(accinfo[0], method='DELETE')
|
||||
except Exception: # fall back to old ipmi-like behavior for such implementations
|
||||
fishclient.set_user_password(uid, base64.b64encode(os.urandom(15)))
|
||||
fishclient.set_user_name(uid, '')
|
||||
return True
|
||||
|
||||
def set_bootdev(self, bootdev, persist=False, uefiboot=None,
|
||||
|
||||
@@ -1662,7 +1662,7 @@ class OEMHandler(generic.OEMHandler):
|
||||
license_errors[rsp['return']])
|
||||
return self.get_licenses(fishclient)
|
||||
|
||||
def user_delete(self, uid):
|
||||
def user_delete(self, uid, fishclient=None):
|
||||
userinfo = self.wc.grab_json_response('/api/dataset/imm_users')
|
||||
uidtonamemap = {}
|
||||
for user in userinfo.get('items', [{'users': []}])[0].get('users', []):
|
||||
|
||||
Reference in New Issue
Block a user