From 88a55b894258187bde91240fff899c47f52d9487 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 19 Feb 2014 19:36:25 -0500 Subject: [PATCH] Add configmanager function to clear attribute. When a caller requests to clear an attribute, if attribute is there and not inherited, it is deleted and then groups are searched for backfill. --- confluent/config/configmanager.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 26c8e9af..df5abdd2 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -602,6 +602,20 @@ class ConfigManager(object): del self._cfgstore['groups'][group] self._bg_sync_to_file() + def clear_node_attributes(self, nodes, attributes): + for node in nodes: + try: + nodek = self._cfgstore['nodes'][node] + except KeyError: + continue + for attrib in attributes: + if attrib in nodek and 'inheritedfrom' not in nodek[attrib]: + # if the attribute is set and not inherited, + # delete it and check for inheritence to backfil data + del nodek[attrib] + self._do_inheritance(nodek, attrib) + self._bg_sync_to_file() + def set_node_attributes(self, attribmap): if 'nodes' not in self._cfgstore: self._cfgstore['nodes'] = {}