From 6ee7b8d138e07bfc37c5cd887f7afa49cdabb02f Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 30 Aug 2019 12:53:15 -0500 Subject: Format location columns in network commands These return a Munch from the SDK, which can be handled exactly like a dict so do that. Note that the location column has a nested project dict in the return value, this is addressed separately in osc_lib.format_columns in https://review.opendev.org/#/c/679474/. Change-Id: I99a6d192749a4ac76777f72be8118261c0521cb0 Signed-off-by: Dean Troyer --- openstackclient/network/v2/network_segment.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'openstackclient/network/v2/network_segment.py') diff --git a/openstackclient/network/v2/network_segment.py b/openstackclient/network/v2/network_segment.py index c1a672e2..5899dc69 100644 --- a/openstackclient/network/v2/network_segment.py +++ b/openstackclient/network/v2/network_segment.py @@ -15,6 +15,7 @@ import logging +from osc_lib.cli import format_columns from osc_lib.command import command from osc_lib import exceptions from osc_lib import utils @@ -26,6 +27,11 @@ from openstackclient.network import sdk_utils LOG = logging.getLogger(__name__) +_formatters = { + 'location': format_columns.DictColumn, +} + + def _get_columns(item): return sdk_utils.get_osc_show_columns_for_sdk_resource(item, {}) @@ -90,7 +96,7 @@ class CreateNetworkSegment(command.ShowOne): attrs['segmentation_id'] = parsed_args.segment obj = client.create_segment(**attrs) display_columns, columns = _get_columns(obj) - data = utils.get_item_properties(obj, columns) + data = utils.get_item_properties(obj, columns, formatters=_formatters) return (display_columns, data) @@ -242,5 +248,5 @@ class ShowNetworkSegment(command.ShowOne): ignore_missing=False ) display_columns, columns = _get_columns(obj) - data = utils.get_item_properties(obj, columns) + data = utils.get_item_properties(obj, columns, formatters=_formatters) return (display_columns, data) -- cgit v1.2.1