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

Merge pull request #12 from jufm/disableuser

Add an option to disable or enable an IPMI user
This commit is contained in:
Jarrod Johnson 2015-08-20 13:36:11 -04:00
commit 56455fe497
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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)