2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-28 20:39:40 +00:00

Implement error on invalid attribute filter

This will cause noderange to probably error out.

Note that invalid attribute names starting with net, power, or custom are treated as always valid.
This commit is contained in:
Jarrod Johnson 2022-06-07 11:45:06 -04:00
parent 0b20e0b634
commit 8bb565e938

View File

@ -1167,6 +1167,18 @@ def hook_new_configmanagers(callback):
pass
def attribute_name_is_invalid(attrname):
if attrname.startswith('custom.') or attrname.startswith('net.') or attrname.startswith('power.'):
return False
if '?' in attrname or '*' in attrname:
for attr in allattributes.node:
if fnmatch.fnmatch(attr, attrname):
return False
return True
attrname = _get_valid_attrname(attrname)
return attrname not in allattributes.node
class ConfigManager(object):
if os.name == 'nt':
_cfgdir = os.path.join(
@ -1275,6 +1287,9 @@ class ConfigManager(object):
raise Exception('Invalid Expression')
if attribute.startswith('secret.'):
raise Exception('Filter by secret attributes is not supported')
if attribute_name_is_invalid(attribute):
raise ValueError(
'{0} is not a valid attribute name'.format(attribute))
for node in nodes:
try:
currvals = [self._cfgstore['nodes'][node][attribute]['value']]