From b907d427f5d479e775d79684617b53c96ddf9ee4 Mon Sep 17 00:00:00 2001 From: Jan Walzer Date: Wed, 5 Jul 2017 13:30:46 +0200 Subject: [PATCH 1/4] nipap-cli address list also shows the tags and attributes This patch makes it possible, to also see the tags and attributes per prefix, when doing an ```nipap-cli address list``` Feedback wanted --- nipap-cli/nipap_cli/nipap_cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nipap-cli/nipap_cli/nipap_cli.py b/nipap-cli/nipap_cli/nipap_cli.py index a08c99a3e..1ef89a97b 100755 --- a/nipap-cli/nipap_cli/nipap_cli.py +++ b/nipap-cli/nipap_cli/nipap_cli.py @@ -522,6 +522,7 @@ def list_prefix(arg, opts, shell_opts): 'added': { 'title': 'Added' }, 'alarm_priority': { 'title': 'Alarm Prio' }, 'authoritative_source': { 'title': 'Auth source' }, + 'avps':{ 'title': 'extra-attributes'}, 'children': { 'title': 'Children' }, 'comment': { 'title': 'Comment' }, 'customer_id': { 'title': 'Customer ID' }, @@ -607,7 +608,6 @@ def list_prefix(arg, opts, shell_opts): pass # override certain column widths col_def['type']['width'] = 1 - col_def['tags']['width'] = 2 col_header_data = {} # build prefix formatting string @@ -631,8 +631,12 @@ def list_prefix(arg, opts, shell_opts): # overwrite some columns due to special handling col_data['tags'] = '-' if len(p.tags) > 0: - col_data['tags'] = '#%d' % len(p.tags) - + col_data['tags'] = ','.join(p.tags) + + col_data['avps'] = '-' + if len(p.avps) > 0: + col_data['avps'] = ', '.join('{}:{}'.format(key,value) for key,value in sorted(p.avps.items())) + try: col_data['pool_name'] = p.pool.name except: From c199abf0bfa174f8dd70ec395e014163b807b0f7 Mon Sep 17 00:00:00 2001 From: Jan Walzer Date: Wed, 5 Jul 2017 13:38:39 +0200 Subject: [PATCH 2/4] Cleanup patch This commit is for cleanup of the nits found when automatically checking the Merge-Request --- nipap-cli/nipap_cli/nipap_cli.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nipap-cli/nipap_cli/nipap_cli.py b/nipap-cli/nipap_cli/nipap_cli.py index 1ef89a97b..1915ae8b1 100755 --- a/nipap-cli/nipap_cli/nipap_cli.py +++ b/nipap-cli/nipap_cli/nipap_cli.py @@ -522,7 +522,7 @@ def list_prefix(arg, opts, shell_opts): 'added': { 'title': 'Added' }, 'alarm_priority': { 'title': 'Alarm Prio' }, 'authoritative_source': { 'title': 'Auth source' }, - 'avps':{ 'title': 'extra-attributes'}, + 'avps':{ 'title': 'Extra-Attributes' }, 'children': { 'title': 'Children' }, 'comment': { 'title': 'Comment' }, 'customer_id': { 'title': 'Customer ID' }, @@ -630,13 +630,13 @@ def list_prefix(arg, opts, shell_opts): # overwrite some columns due to special handling col_data['tags'] = '-' - if len(p.tags) > 0: + if len(p.tags) > 0: col_data['tags'] = ','.join(p.tags) - + col_data['avps'] = '-' - if len(p.avps) > 0: - col_data['avps'] = ', '.join('{}:{}'.format(key,value) for key,value in sorted(p.avps.items())) - + if len(p.avps) > 0: + col_data['avps'] = ','.join('{}:{}'.format(key, value) for key, value in sorted(p.avps.items())) + try: col_data['pool_name'] = p.pool.name except: From 52e5902210d1375a97e458eb2529cf3e93c095ab Mon Sep 17 00:00:00 2001 From: Jan Walzer Date: Wed, 5 Jul 2017 13:40:32 +0200 Subject: [PATCH 3/4] Another coding-style cleanup --- nipap-cli/nipap_cli/nipap_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipap-cli/nipap_cli/nipap_cli.py b/nipap-cli/nipap_cli/nipap_cli.py index 1915ae8b1..d921153f1 100755 --- a/nipap-cli/nipap_cli/nipap_cli.py +++ b/nipap-cli/nipap_cli/nipap_cli.py @@ -522,7 +522,7 @@ def list_prefix(arg, opts, shell_opts): 'added': { 'title': 'Added' }, 'alarm_priority': { 'title': 'Alarm Prio' }, 'authoritative_source': { 'title': 'Auth source' }, - 'avps':{ 'title': 'Extra-Attributes' }, + 'avps': { 'title': 'Extra-Attributes' }, 'children': { 'title': 'Children' }, 'comment': { 'title': 'Comment' }, 'customer_id': { 'title': 'Customer ID' }, From 6659000f9201511b2f0805064d9129cded64cfe6 Mon Sep 17 00:00:00 2001 From: Jan Walzer Date: Wed, 5 Jul 2017 13:41:39 +0200 Subject: [PATCH 4/4] Update nipap_cli.py --- nipap-cli/nipap_cli/nipap_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nipap-cli/nipap_cli/nipap_cli.py b/nipap-cli/nipap_cli/nipap_cli.py index d921153f1..64d109f41 100755 --- a/nipap-cli/nipap_cli/nipap_cli.py +++ b/nipap-cli/nipap_cli/nipap_cli.py @@ -630,11 +630,11 @@ def list_prefix(arg, opts, shell_opts): # overwrite some columns due to special handling col_data['tags'] = '-' - if len(p.tags) > 0: + if len(p.tags) > 0: col_data['tags'] = ','.join(p.tags) col_data['avps'] = '-' - if len(p.avps) > 0: + if len(p.avps) > 0: col_data['avps'] = ','.join('{}:{}'.format(key, value) for key, value in sorted(p.avps.items())) try: