mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-27 19:37:57 +00:00
Implement 'unset' in confetty interactive cli.
Provide a means to clear node specific settings so that inheritance can be restored. In JSON, send a null as a value for a parameter instead of a string or 'object'.
This commit is contained in:
parent
7c7754d319
commit
ea7d3a268c
16
bin/confetty
16
bin/confetty
@ -70,6 +70,7 @@ valid_commands = [
|
||||
'cd',
|
||||
'show',
|
||||
'set',
|
||||
'unset',
|
||||
'create',
|
||||
]
|
||||
|
||||
@ -234,9 +235,24 @@ def do_command(command, server):
|
||||
return
|
||||
elif argv[0] == 'set':
|
||||
setvalues(argv[1:])
|
||||
elif argv[0] in ('unset', 'clear'):
|
||||
clearvalues(argv[1], argv[2:])
|
||||
else:
|
||||
sys.stderr.write("%s: command not found...\n" % argv[0])
|
||||
|
||||
|
||||
def clearvalues(resource, attribs):
|
||||
targpath = fullpath_target(resource)
|
||||
keydata = {}
|
||||
for attrib in attribs:
|
||||
keydata[attrib] = None
|
||||
for res in send_request('update', targpath, server, keydata):
|
||||
if 'error' in res:
|
||||
if 'errorcode' in res:
|
||||
exitcode = res['errorcode']
|
||||
sys.stderr.write('Error: ' + res['error'] + '\n')
|
||||
|
||||
|
||||
def setvalues(attribs):
|
||||
if '=' in attribs[0]: # going straight to attribute
|
||||
resource = attribs[0][:attribs[0].index("=")]
|
||||
|
@ -125,12 +125,20 @@ def update_nodegroup(group, element, configmanager, inputdata):
|
||||
except ValueError:
|
||||
raise exc.InvalidArgumentException()
|
||||
return retrieve_nodegroup(group, element, configmanager, inputdata)
|
||||
|
||||
|
||||
def update_nodes(nodes, element, configmanager, inputdata):
|
||||
updatedict = {}
|
||||
for node in nodes:
|
||||
updatenode = inputdata.get_attributes(node)
|
||||
clearattribs = []
|
||||
if updatenode:
|
||||
for attrib in updatenode.iterkeys():
|
||||
if updatenode[attrib] is None:
|
||||
clearattribs.append(attrib)
|
||||
if len(clearattribs) > 0:
|
||||
for attrib in clearattribs:
|
||||
del updatenode[attrib]
|
||||
configmanager.clear_node_attributes([node], clearattribs)
|
||||
updatedict[node] = updatenode
|
||||
try:
|
||||
configmanager.set_node_attributes(updatedict)
|
||||
|
Loading…
x
Reference in New Issue
Block a user