diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index f5163a6b..08cad09c 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -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' diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 4e5bd879..4983f526 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -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])