From 0afd9beeac96a612ac6920b1a02271a2d9abe0fc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 5 Feb 2018 15:23:13 -0500 Subject: [PATCH] Fix nodeconfig error handling Additionally, make more strong effort to sort the data. --- confluent_client/bin/nodeconfig | 15 ++++++++++++--- confluent_client/confluent/client.py | 4 ++-- confluent_server/confluent/messages.py | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/confluent_client/bin/nodeconfig b/confluent_client/bin/nodeconfig index 54005b84..d6a00f34 100755 --- a/confluent_client/bin/nodeconfig +++ b/confluent_client/bin/nodeconfig @@ -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) \ No newline at end of file diff --git a/confluent_client/confluent/client.py b/confluent_client/confluent/client.py index 5e5efe8d..bfe62756 100644 --- a/confluent_client/confluent/client.py +++ b/confluent_client/confluent/client.py @@ -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] diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 2f75c4e0..13331f11 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -35,7 +35,7 @@ valid_health_values = set([ def _htmlify_structure(indict): ret = "