2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-18 05:33:17 +00:00

Implement list all IPMI users.

This commit is contained in:
Juliana Motira 2015-08-06 07:21:56 -03:00
parent 7a084bf538
commit c263c2eebb
2 changed files with 29 additions and 1 deletions

View File

@ -326,7 +326,7 @@ def get_input_message(path, operation, inputdata, nodes=None, multinode=False):
elif path == ['events', 'hardware', 'decode']:
return InputAlertData(path, inputdata, nodes)
elif (path[:3] == ['configuration', 'management_controller', 'users'] and
operation != 'retrieve' and operation != 'delete'):
operation not in ('retrieve', 'delete') and path[-1] != 'all'):
return InputCredential(path, inputdata, nodes)
elif inputdata:
raise exc.InvalidArgumentException()
@ -686,6 +686,26 @@ class User(ConfluentMessage):
self.kvpairs = {name: kvpairs}
class UserCollection(ConfluentMessage):
readonly = True
def __init__(self, users=(), name=None):
self.notnode = name is None
self.desc = 'list of users'
userlist = []
for user in users:
entry = {
'uid': user['uid'],
'username': user['name'],
'privilege_level': user['access']['privilege_level']
}
userlist.append(entry)
if self.notnode:
self.kvpairs = {'users': userlist}
else:
self.kvpairs = {name: {'users': userlist}}
class AlertDestination(ConfluentMessage):
def __init__(self, ip, acknowledge=False, retries=0, name=None):
self.desc = 'foo'

View File

@ -447,9 +447,17 @@ class IpmiHandler(object):
callback=True,link_auth=True, ipmi_msg=True,
privilege_level=user['privilege_level'])
# A list of users
self.output.put(msg.ChildCollection('all'))
for user in self.ipmicmd.get_users():
self.output.put(msg.ChildCollection(user, candelete=True))
return
# List all users
elif len(self.element) == 4 and self.element[-1] == 'all':
users = []
for user in self.ipmicmd.get_users():
users.append(self.ipmicmd.get_user(uid=user))
self.output.put(msg.UserCollection(users=users, name=self.node))
return
# Update user
elif len(self.element) == 4:
user = int(self.element[-1])