summaryrefslogtreecommitdiff
path: root/openstackclient/network/v2
diff options
context:
space:
mode:
authorSławek Kapłoński <slawek@kaplonski.pl>2018-05-10 17:16:48 +0200
committerSlawek Kaplonski <skaplons@redhat.com>2018-05-25 19:45:13 +0000
commit8db3933feb35f91f3ff3d121c155286973c66122 (patch)
treea7a220a38f0e1176fa8a9aa27a7c5d0c5be08d97 /openstackclient/network/v2
parentf7e4d31820e797e0d374e7dfde1142373245ea87 (diff)
downloadpython-openstackclient-8db3933feb35f91f3ff3d121c155286973c66122.tar.gz
Don't display router's is_ha and is_distributed attributes always
In case when is_ha or is_distributed attribute of Neutron's router is set to None, it means that it wasn't returned from server and should not be displayed. Otherwise it might be confusing for user is making openstack router show <router_name> call as an admin will return e.g. is_ha=True but same call done as regular user will return False or None. It might happen like that because returning of those attributes is forbidden for regular users in Neutron's policy.json Depends-On: https://review.openstack.org/567606/ Change-Id: I626b5193d9ecb308baad7b27939f9673c32b4182 Closes-Bug: #1689510 Task: 19789 Story: 2002110
Diffstat (limited to 'openstackclient/network/v2')
-rw-r--r--openstackclient/network/v2/router.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py
index f0a51967..4819f279 100644
--- a/openstackclient/network/v2/router.py
+++ b/openstackclient/network/v2/router.py
@@ -71,7 +71,15 @@ def _get_columns(item):
}
if hasattr(item, 'interfaces_info'):
column_map['interfaces_info'] = 'interfaces_info'
- return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map)
+ invisible_columns = []
+ if item.is_ha is None:
+ invisible_columns.append('is_ha')
+ column_map.pop('is_ha')
+ if item.is_distributed is None:
+ invisible_columns.append('is_distributed')
+ column_map.pop('is_distributed')
+ return sdk_utils.get_osc_show_columns_for_sdk_resource(
+ item, column_map, invisible_columns)
def _get_attrs(client_manager, parsed_args):
@@ -330,8 +338,6 @@ class ListRouter(command.Lister):
'name',
'status',
'is_admin_state_up',
- 'is_distributed',
- 'is_ha',
'project_id',
)
column_headers = (
@@ -339,8 +345,6 @@ class ListRouter(command.Lister):
'Name',
'Status',
'State',
- 'Distributed',
- 'HA',
'Project',
)
@@ -376,6 +380,16 @@ class ListRouter(command.Lister):
else:
data = client.routers(**args)
+ # check if "HA" and "Distributed" columns should be displayed also
+ data = list(data)
+ for d in data:
+ if (d.is_distributed is not None and
+ 'is_distributed' not in columns):
+ columns = columns + ('is_distributed',)
+ column_headers = column_headers + ('Distributed',)
+ if d.is_ha is not None and 'is_ha' not in columns:
+ columns = columns + ('is_ha',)
+ column_headers = column_headers + ('HA',)
if parsed_args.long:
columns = columns + (
'routes',