From 938a6e44df44f5b07a1549a4a1b4e0aa5fd70d24 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 25 Feb 2019 15:23:54 -0500 Subject: [PATCH] Add checking for noderange conflict A confluent nodegroup may either be a normal static one, which can be used for attribute inheritence, or a dynamic one, which cannot be used with static list or static attributes. Warn the user when they try to set that up to make it more obvious that the dynamic groups can't do what they are trying to do. --- confluent_server/confluent/config/configmanager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 76f8ae74..9bf9ed86 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -1499,6 +1499,9 @@ class ConfigManager(object): newattr = _attraliases[attr] attribmap[group][newattr] = attribmap[group][attr] del attribmap[group][attr] + if 'noderange' in attribmap[group]: + if len(attribmap[group]) > 1: + raise ValueErorr('noderange attribute must be set by itself') for attr in attribmap[group]: if attr in _attraliases: newattr = _attraliases[attr] @@ -1541,6 +1544,13 @@ class ConfigManager(object): if group not in self._cfgstore['nodegroups']: self._cfgstore['nodegroups'][group] = {'nodes': set()} cfgobj = self._cfgstore['nodegroups'][group] + if 'noderange' in attribmap[group] and attribmap[group]['noderange']: + if cfgobj['nodes']: + raise ValueError('Cannot set both nodes and noderange on group') + if set(cfgobj) - set(['noderange', 'nodes']): + raise ValueError('Cannot set noderange on a group with attributes') + elif 'noderange' in cfgobj and cfgobj['noderange']: + raise ValueError('Attributes cannot be set on a group with a noderange') for attr in attribmap[group]: if attr == 'nodes': newdict = set(attribmap[group][attr])