mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +00:00
Support list style attributes (notably groups) in the api explorer
This commit is contained in:
parent
57fe5cfcce
commit
ecc7c21fc4
@ -563,11 +563,10 @@ class ConfigManager(object):
|
||||
recalcexpressions = False
|
||||
for attrname in attribmap[node].iterkeys():
|
||||
newdict = {}
|
||||
if (isinstance(attribmap[node][attrname], dict) or
|
||||
isinstance(attribmap[node][attrname], set)):
|
||||
newdict = attribmap[node][attrname]
|
||||
else:
|
||||
if (isinstance(attribmap[node][attrname], str)):
|
||||
newdict = {'value': attribmap[node][attrname] }
|
||||
else:
|
||||
newdict = attribmap[node][attrname]
|
||||
if 'value' in newdict and attrname.startswith("secret."):
|
||||
newdict['cryptvalue' ] = crypt_value(newdict['value'])
|
||||
del newdict['value']
|
||||
|
@ -33,6 +33,18 @@ class ConfluentMessage(object):
|
||||
value = val['value']
|
||||
if 'note' in val:
|
||||
note = '(' + val['note'] + ')'
|
||||
if isinstance(val, list):
|
||||
snippet += key + ":"
|
||||
for v in val:
|
||||
snippet += \
|
||||
'<input type="%s" name="%s" value="%s">%s' % (
|
||||
type, key, v, note)
|
||||
snippet += \
|
||||
'<input type="%s" name="%s" value="">%s' % (
|
||||
type, key, note)
|
||||
snippet += '<input type="checkbox" name="restexplorerhonorkey" '
|
||||
snippet += 'value="%s">' % (key)
|
||||
return snippet
|
||||
snippet += key + ":" + \
|
||||
'<input type="%s" name="%s" value="%s">%s' % (
|
||||
type, key, value, note)
|
||||
@ -212,6 +224,12 @@ class Attributes(ConfluentMessage):
|
||||
node: nkv
|
||||
}
|
||||
|
||||
class ListAttributes(ConfluentMessage):
|
||||
def __init__(self, node, kv):
|
||||
self .kvpairs = {
|
||||
node: kv
|
||||
}
|
||||
|
||||
class CryptedAttributes(Attributes):
|
||||
defaultvalue = 'dummyvalue'
|
||||
defaulttype = 'password'
|
||||
|
@ -26,6 +26,9 @@ def retrieve(nodes, element, configmanager, inputdata):
|
||||
elif 'cryptvalue' in currattr:
|
||||
yield msg.CryptedAttributes(node,
|
||||
{attribute: currattr['cryptvalue']})
|
||||
elif isinstance(currattr, list):
|
||||
yield msg.ListAttributes(node,
|
||||
{attribute: currattr})
|
||||
else:
|
||||
print repr(currattr)
|
||||
raise Exception("BUGGY ATTRIBUTE FOR NODE")
|
||||
|
Loading…
Reference in New Issue
Block a user