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

Extend and document user_delete in ipmi.command

User deletion has some limitations making the function a best effort.
Document this and provide at least one additional attempt at deleting
a user to cover more vendors.  This still does not cover all vendors,
and OEM extensibility is likely to be the answer to allow this to
cover more implementations.

Change-Id: I6af3f761c587f9eb8b58b3408052d6585847f7d6
This commit is contained in:
Jarrod Johnson 2015-07-07 10:43:59 -04:00
parent 5b7bd84895
commit cf01aa5fdb

View File

@ -1331,16 +1331,29 @@ class Command(object):
def user_delete(self, uid, channel=None):
"""Delete user (helper)
Note that in IPMI, user 'deletion' isn't a concept. This function
will make a best effort to provide the expected result (e.g.
web interfaces skipping names and ipmitool skipping as well.
:param uid: user number [1:16]
:param channel: number [1:7]
"""
# TODO(jjohnson2): Provide OEM extensibility to cover user deletion
if channel is None:
channel = self.get_network_channel()
self.set_user_password(uid, mode='disable', password=None)
self.set_user_name(uid, '')
# TODO(steveweber) perhaps should set user access on all channels
# so new users dont get extra access
self.set_user_access(uid, channel=channel, callback=False,
link_auth=False, ipmi_msg=False,
privilege_level='no_access')
try:
# First try to set name to all \x00 explicitly
self.set_user_name(uid, '')
except Exception:
# An invalid data field in request is frequently reported.
# however another convention that exists is all '\xff'
# if this fails, pass up the error so that calling code knows
# that the deletion did not go as planned for now
self.set_user_name(uid, '\xff' * 16)
return True