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

Fix nodeconfig error handling

Additionally, make more strong effort to sort the data.
This commit is contained in:
Jarrod Johnson 2018-02-05 15:23:13 -05:00
parent b37ef7e90c
commit 0afd9beeac
3 changed files with 17 additions and 8 deletions

View File

@ -119,6 +119,7 @@ for param in args[1:]:
queryparms[path] = {}
queryparms[path][attrib] = param
session = client.Command()
rcode = 0
if setmode:
updatebypath = {}
attrnamebypath = {}
@ -136,10 +137,17 @@ if setmode:
# well, we want to expand things..
# check ipv4, if requested change method to static
for path in updatebypath:
for r in session.update('/noderange/{0}/{1}'.format(noderange, path),
for fr in session.update('/noderange/{0}/{1}'.format(noderange, path),
updatebypath[path]):
for node in r:
keyval = r[node]['value']
for node in fr['databynode']:
r = fr['databynode'][node]
if 'error' in r:
sys.stderr.write(node + ': ' + r['error'] + '\n')
if 'errorcode' in r:
rcode |= r['errorcode']
if 'value' not in r:
continue
keyval = r['value']
key, val = keyval.split('=')
if key in attrnamebypath[path]:
key = attrnamebypath[path][key]
@ -154,3 +162,4 @@ else:
path = '/noderange/{0}/configuration/system/all'.format(noderange)
client.print_attrib_path(path, session, printsys,
NullOpt())
sys.exit(rcode)

View File

@ -312,8 +312,8 @@ def print_attrib_path(path, session, requestargs, options, rename=None):
sys.stderr.write(res['error'] + '\n')
exitcode = 1
continue
for node in res['databynode']:
for attr in res['databynode'][node]:
for node in sorted(res['databynode']):
for attr in sorted(res['databynode'][node]):
seenattributes.add(attr)
if rename and attr in rename:
printattr = rename[attr]

View File

@ -35,7 +35,7 @@ valid_health_values = set([
def _htmlify_structure(indict):
ret = "<ul>"
if isinstance(indict, dict):
for key in indict.iterkeys():
for key in sorted(indict):
ret += "<li>{0}: ".format(key)
if type(indict[key]) in (str, unicode, float, int):
ret += str(indict[key])
@ -77,7 +77,7 @@ class ConfluentMessage(object):
datasource = self.kvpairs
else:
datasource = {'databynode': self.kvpairs}
jsonsnippet = json.dumps(datasource, separators=(',', ':'))[1:-1]
jsonsnippet = json.dumps(datasource, sort_keys=True, separators=(',', ':'))[1:-1]
return jsonsnippet
def raw(self):
@ -1261,7 +1261,7 @@ class Attributes(ConfluentMessage):
self.desc = desc
nkv = {}
self.notnode = name is None
for key in kv.iterkeys():
for key in kv:
if type(kv[key]) in (str, unicode):
nkv[key] = {'value': kv[key]}
else: