diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-03-10 02:52:15 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-03-10 02:52:15 +0000 |
| commit | 9ffcd0dca73503f5385b2028de30290d086ae58e (patch) | |
| tree | 981781b83af41463bec4f2fdb857cc9384c707ea /openstackclient/network | |
| parent | 1e739d7aebe53d38038b9f6172eb08916a7dd23c (diff) | |
| parent | 3e6356a4d87351c84a29e3a44f60f0544e2947b6 (diff) | |
| download | python-openstackclient-9ffcd0dca73503f5385b2028de30290d086ae58e.tar.gz | |
Merge "Fix handling the use_default_subnet_pool attribute"
Diffstat (limited to 'openstackclient/network')
| -rw-r--r-- | openstackclient/network/sdk_utils.py | 23 | ||||
| -rw-r--r-- | openstackclient/network/v2/subnet.py | 10 |
2 files changed, 29 insertions, 4 deletions
diff --git a/openstackclient/network/sdk_utils.py b/openstackclient/network/sdk_utils.py index 7bd54e46..04f168be 100644 --- a/openstackclient/network/sdk_utils.py +++ b/openstackclient/network/sdk_utils.py @@ -13,8 +13,24 @@ import six -# Get the OSC show command display and attribute columns for an SDK resource. -def get_osc_show_columns_for_sdk_resource(sdk_resource, osc_column_map): +def get_osc_show_columns_for_sdk_resource( + sdk_resource, + osc_column_map, + invisible_columns=[] +): + """Get and filter the display and attribute columns for an SDK resource. + + Common utility function for preparing the output of an OSC show command. + Some of the columns may need to get renamed, others made invisible. + + :param sdk_resource: An SDK resource + :param osc_column_map: A hash of mappings for display column names + :param invisible_columns: A list of invisible column names + + :returns: Two tuples containing the names of the display and attribute + columns + """ + if getattr(sdk_resource, 'allow_get', None) is not None: resource_dict = sdk_resource.to_dict( body=True, headers=False, ignore_none=False) @@ -24,6 +40,9 @@ def get_osc_show_columns_for_sdk_resource(sdk_resource, osc_column_map): # Build the OSC column names to display for the SDK resource. attr_map = {} display_columns = list(resource_dict.keys()) + for col_name in invisible_columns: + if col_name in display_columns: + display_columns.remove(col_name) for sdk_attr, osc_attr in six.iteritems(osc_column_map): if sdk_attr in display_columns: attr_map[osc_attr] = sdk_attr diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py index 2771858b..403b4cd2 100644 --- a/openstackclient/network/v2/subnet.py +++ b/openstackclient/network/v2/subnet.py @@ -132,7 +132,13 @@ def _get_columns(item): 'subnet_pool_id': 'subnetpool_id', 'tenant_id': 'project_id', } - return sdk_utils.get_osc_show_columns_for_sdk_resource(item, column_map) + # Do not show this column when displaying a subnet + invisible_columns = ['use_default_subnetpool'] + return sdk_utils.get_osc_show_columns_for_sdk_resource( + item, + column_map, + invisible_columns=invisible_columns + ) def convert_entries_to_nexthop(entries): @@ -179,7 +185,7 @@ def _get_attrs(client_manager, parsed_args, is_create=True): ignore_missing=False) attrs['subnetpool_id'] = subnet_pool.id if parsed_args.use_default_subnet_pool: - attrs['use_default_subnetpool'] = True + attrs['use_default_subnet_pool'] = True if parsed_args.prefix_length is not None: attrs['prefixlen'] = parsed_args.prefix_length if parsed_args.subnet_range is not None: |
