mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 19:10:10 +00:00
Implement the ability to delete users
This commit is contained in:
parent
1b7a18c108
commit
e9422e3c4d
@ -184,10 +184,10 @@ def do_command(command, server):
|
||||
global currconsole
|
||||
global currchildren
|
||||
exitcode = 0
|
||||
command = command.lower()
|
||||
argv = parse_command(command)
|
||||
if len(argv) == 0:
|
||||
return
|
||||
argv[0] = argv[0].lower()
|
||||
if argv[0] == 'exit':
|
||||
sys.exit(0)
|
||||
elif argv[0] == 'cd':
|
||||
|
@ -526,6 +526,13 @@ class ConfigManager(object):
|
||||
user[attribute] = attributemap[attribute]
|
||||
self._bg_sync_to_file()
|
||||
|
||||
def del_user(self, name):
|
||||
changeset = {}
|
||||
if name in self._cfgstore['users']:
|
||||
_mark_dirtykey('users', name, self.tenant)
|
||||
del self._cfgstore['users'][name]
|
||||
self._bg_sync_to_file()
|
||||
|
||||
def create_user(self, name,
|
||||
role="Administrator", id=None, displayname=None,
|
||||
attributemap=None):
|
||||
@ -992,7 +999,6 @@ class ConfigManager(object):
|
||||
del globalf[globalkey]
|
||||
globalf.close()
|
||||
if 'dirtykeys' in _cfgstore:
|
||||
#with lock:
|
||||
with _dirtylock:
|
||||
currdirt = copy.deepcopy(_cfgstore['dirtykeys'])
|
||||
del _cfgstore['dirtykeys']
|
||||
|
@ -172,6 +172,10 @@ def iterate_resources(fancydict):
|
||||
yield msg.ChildCollection(resource)
|
||||
|
||||
|
||||
def delete_user(user, configmanager):
|
||||
configmanager.del_user(user)
|
||||
yield msg.DeletedResource(user)
|
||||
|
||||
def delete_nodegroup_collection(collectionpath, configmanager):
|
||||
if len(collectionpath) == 2: # just the nodegroup
|
||||
group = collectionpath[-1]
|
||||
@ -330,6 +334,8 @@ def handle_path(path, operation, configmanager, inputdata=None):
|
||||
else:
|
||||
return stripnode(passvalue, node)
|
||||
elif pathcomponents[0] == 'users':
|
||||
#TODO: when non-administrator accounts exist,
|
||||
# they must only be allowed to see their own user
|
||||
try:
|
||||
user = pathcomponents[1]
|
||||
except IndexError: # it's just users/
|
||||
@ -338,14 +344,13 @@ def handle_path(path, operation, configmanager, inputdata=None):
|
||||
pathcomponents, operation, inputdata)
|
||||
create_user(inputdata.attribs, configmanager)
|
||||
return iterate_collections(configmanager.list_users(), forcecollection=False)
|
||||
inputdata = msg.get_input_message(
|
||||
pathcomponents, operation, inputdata)
|
||||
if operation == 'retrieve':
|
||||
return show_user(user, configmanager)
|
||||
elif operation == 'delete':
|
||||
delete_user(user, configmanager)
|
||||
return show_user(user, configmanager)
|
||||
return delete_user(user, configmanager)
|
||||
elif operation == 'update':
|
||||
inputdata = msg.get_input_message(
|
||||
pathcomponents, operation, inputdata)
|
||||
update_user(user, inputdata.attribs, configmanager)
|
||||
return show_user(user, configmanager)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user