diff --git a/bin/confetty b/bin/confetty index 3ef592bf..7fbbb2bc 100755 --- a/bin/confetty +++ b/bin/confetty @@ -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': diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index d47c7c62..5b253c06 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -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'] diff --git a/confluent/pluginapi.py b/confluent/pluginapi.py index 6ecfa9bb..459b6061 100644 --- a/confluent/pluginapi.py +++ b/confluent/pluginapi.py @@ -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: