2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Add support for showing all as well as current attributes

This commit is contained in:
Jarrod Johnson 2013-11-03 10:36:03 -05:00
parent 58482c6090
commit 659f85eaa0
3 changed files with 33 additions and 13 deletions

View File

@ -131,7 +131,7 @@ node = {
'The managed node.')
},
'virtualization.host': {
'description': ('Hypervisor where this node does/should reside',
'description': ('Hypervisor where this node does/should reside'),
'appliesto': ['vm'],
},
'virtualization.computepool': {

View File

@ -57,6 +57,8 @@ nodetree = {
'/console/': ['session', 'logging'],
'/attributes/all': [], # TODO: put in the 'categories' automaticly from
# confluent.config.attributes
'/attributes/current': [], # TODO: put in the 'categories' automaticly from
# confluent.config.attributes
}
# _ elements are for internal use (e.g. special console scheme)
@ -78,6 +80,9 @@ nodeelements = {
'attributes/all': {
'handler': 'attributes',
},
'attributes/current': {
'handler': 'attributes',
},
}
def stripnode(iterablersp, node):

View File

@ -1,19 +1,34 @@
import confluent.messages as msg
import confluent.config.attributes as allattributes
def retrieve(nodes, element, configmanager, inputdata):
attributes = configmanager.get_node_attributes(nodes)
for node in attributes.iterkeys():
for attribute in attributes[node].iterkeys():
currattr = attributes[node][attribute]
if 'value' in currattr:
yield msg.Attributes(node,
{attribute: currattr['value']})
elif 'cryptvalue' in currattr:
yield msg.CryptedAttributes(node,
{attribute: currattr['cryptvalue']})
else:
print repr(currattr)
raise Exception("BUGGY ATTRIBUTE FOR NODE")
if element.endswith('/all'):
for node in nodes:
for attribute in sorted(allattributes.node.iterkeys()):
if attribute in attributes[node]: #have a setting for it
val = attributes[node][attribute]
else: # no setting, provide a blank
val = {'value': '', 'cryptvalue': ''}
if attribute.startswith('secret.'):
yield msg.CryptedAttributes(node,
{attribute: val})
else:
yield msg.Attributes(node,
{attribute: val['value']})
elif element.endswith('/current'):
for node in attributes.iterkeys():
for attribute in sorted(attributes[node].iterkeys()):
currattr = attributes[node][attribute]
if 'value' in currattr:
yield msg.Attributes(node,
{attribute: currattr['value']})
elif 'cryptvalue' in currattr:
yield msg.CryptedAttributes(node,
{attribute: currattr['cryptvalue']})
else:
print repr(currattr)
raise Exception("BUGGY ATTRIBUTE FOR NODE")
def update(nodes, element, configmanager, inputdata):