diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 08cad09c..c5441efa 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -421,6 +421,11 @@ class InputCredential(ConfluentMessage): 'no_access', ]) + valid_enabled_values = set([ + 'yes', + 'no' + ]) + def __init__(self, path, inputdata, nodes=None): self.credentials = {} nestedmode = False @@ -451,6 +456,11 @@ class InputCredential(ConfluentMessage): if 'password' in inputdata and len(inputdata['password']) > 20: raise exc.InvalidArgumentException('password has limit of 20 chars') + if ('enabled' in inputdata and + inputdata['enabled'] not in self.valid_enabled_values): + raise exc.InvalidArgumentException('valid values for enabled are ' + + 'yes and no') + if nodes is None: raise exc.InvalidArgumentException( 'This only supports per-node input') @@ -678,7 +688,8 @@ class User(ConfluentMessage): self.notnode = name is None kvpairs = {'username': {'value': username}, 'password': {'value': '', 'type': 'password'}, - 'privilege_level': {'value': privilege_level} + 'privilege_level': {'value': privilege_level}, + 'enabled': {'value': ''} } if self.notnode: self.kvpairs = kvpairs diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index a03e67b9..75c2393b 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -483,6 +483,12 @@ class IpmiHandler(object): password=user['password']) self.ipmicmd.set_user_password(uid=user['uid'], mode='enable', password=user['password']) + if 'enabled' in user: + if user['enabled'] == 'yes': + mode = 'enable' + else: + mode = 'disable' + self.ipmicmd.disable_user(user['uid'], mode) return elif self.op == 'delete': self.ipmicmd.user_delete(uid=user)