diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index ebb1dfd7..24b2dad4 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -1837,7 +1837,7 @@ class ConfigManager(object): if self.tenant in self._nodecollwatchers: nodecollwatchers = self._nodecollwatchers[self.tenant] for watcher in nodecollwatchers.itervalues(): - eventlet.spawn_n(_do_add_watcher, watcher, None, self, renamemap) + eventlet.spawn_n(_do_add_watcher, watcher, (), self, renamemap) self._bg_sync_to_file() def set_node_attributes(self, attribmap, autocreate=False): diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 90382558..bf5acf46 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -267,6 +267,17 @@ class CreatedResource(ConfluentMessage): pass +class RenamedResource(ConfluentMessage): + notnode = True + readonly = True + + def __init__(self, oldname, newname): + self.kvpairs = {'oldname': oldname, 'newname': newname} + + def strip_node(self, node): + pass + + class AssignedResource(ConfluentMessage): notnode = True readonly = True @@ -381,6 +392,8 @@ def get_input_message(path, operation, inputdata, nodes=None, multinode=False, return InputReseatMessage(path, nodes, inputdata) elif path == ['attributes', 'expression']: return InputExpression(path, inputdata, nodes) + elif path == ['attributes', 'rename']: + return InputConfigChangeSet(path, inputdata, nodes, configmanager) elif path[0] in ('attributes', 'users') and operation != 'retrieve': return InputAttributes(path, inputdata, nodes) elif path == ['boot', 'nextdevice'] and operation != 'retrieve': @@ -539,8 +552,6 @@ class InputConfigClear(ConfluentMessage): raise exc.InvalidArgumentException('Input must be {"clear":true}') class InputConfigChangeSet(InputExpression): - # For now, this is identical to InputExpression, later it may - # internalize formula expansion, but not now.. def __init__(self, path, inputdata, nodes=None, configmanager=None): self.cfm = configmanager super(InputConfigChangeSet, self).__init__(path, inputdata, nodes) diff --git a/confluent_server/confluent/plugins/configuration/attributes.py b/confluent_server/confluent/plugins/configuration/attributes.py index c9dda221..bf5a9e70 100644 --- a/confluent_server/confluent/plugins/configuration/attributes.py +++ b/confluent_server/confluent/plugins/configuration/attributes.py @@ -200,12 +200,23 @@ def create(nodes, element, configmanager, inputdata): if nodes is not None and element[-1] == 'expression': return _expand_expression(nodes, configmanager, inputdata) +def yield_rename_resources(namemap): + for node in namemap: + yield msg.RenamedResource(node, namemap[node]) + def update_nodes(nodes, element, configmanager, inputdata): updatedict = {} if not nodes: raise exc.InvalidArgumentException( 'No action to take, noderange is empty (if trying to define ' 'group attributes, use nodegroupattrib)') + if 'rename' in element: + namemap = {} + for node in nodes: + rename = inputdata.get_attributes(node) + namemap[node] = rename['rename'] + configmanager.rename_nodes(namemap) + return yield_rename_resources(namemap) for node in nodes: updatenode = inputdata.get_attributes(node, allattributes.node) clearattribs = []