2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Improve the get_nodegroup_attribute to be more full featured

Also, move masking of the _expressionkeys attribute into the core
of the class rather than working around it.
This commit is contained in:
Jarrod Johnson 2014-02-19 20:36:39 -05:00
parent f2c09795ff
commit a68deebec8
2 changed files with 22 additions and 8 deletions

View File

@ -423,7 +423,18 @@ class ConfigManager(object):
return self._cfgstore['nodes'].iterkeys()
def get_nodegroup_attributes(self, nodegroup, attributes=[]):
return self._cfgstore['groups'][nodegroup]
cfgnodeobj = self._cfgstore['groups'][nodegroup]
if len(attributes) == 0:
attributes = cfgnodeobj.iterkeys()
nodeobj = {}
for attribute in attributes:
if attribute.startswith('_'):
continue
if attribute not in cfgnodeobj:
continue
nodeobj[attribute] = _decode_attribute(attribute, cfgnodeobj,
decrypt=self.decrypt)
return nodeobj
def get_node_attributes(self, nodelist, attributes=[]):
if 'nodes' not in self._cfgstore:
@ -439,8 +450,14 @@ class ConfigManager(object):
if len(attributes) == 0:
attributes = cfgnodeobj.iterkeys()
for attribute in attributes:
if attribute.startswith('_'):
# skip private things
continue
if attribute not in cfgnodeobj:
continue
# since the formatter is not passed in, the calculator is
# skipped. The decryption, however, we want to do only on
# demand
nodeobj[attribute] = _decode_attribute(attribute, cfgnodeobj,
decrypt=self.decrypt)
retdict[node] = nodeobj

View File

@ -36,8 +36,6 @@ def retrieve_nodegroup(nodegroup, element, configmanager, inputdata):
desc=allattributes.node[attribute]['description'])
if element == 'current':
for attribute in sorted(grpcfg.iterkeys()):
if attribute.startswith("_"):
continue
currattr = grpcfg[attribute]
desc=""
if attribute == 'nodes':
@ -51,6 +49,10 @@ def retrieve_nodegroup(nodegroup, element, configmanager, inputdata):
yield msg.Attributes(
kv={attribute: currattr['value']},
desc=desc)
elif 'expression' in currattr:
yield msg.Attributes(
kv={attribute: currattr['expression']},
desc=desc)
elif 'cryptvalue' in currattr:
yield msg.CryptedAttributes(
kv={attribute: currattr},
@ -74,9 +76,6 @@ def retrieve_nodes(nodes, element, configmanager, inputdata):
if element[-1] == 'all':
for node in nodes:
for attribute in sorted(allattributes.node.iterkeys()):
if attribute.startswith("_"):
# a 'private' attribute
continue
if attribute in attributes[node]: #have a setting for it
val = attributes[node][attribute]
elif attribute == 'groups': # no setting, provide a blank
@ -98,8 +97,6 @@ def retrieve_nodes(nodes, element, configmanager, inputdata):
elif element[-1] == 'current':
for node in attributes.iterkeys():
for attribute in sorted(attributes[node].iterkeys()):
if attribute.startswith("_"):
continue
currattr = attributes[node][attribute]
try:
desc = allattributes.node[attribute]['description']