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 <dtroyer@gmail.com>
This commit is contained in:
Dean Troyer 2019-08-30 12:53:15 -05:00
parent eed615e7d0
commit 6ee7b8d138
22 changed files with 119 additions and 28 deletions

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'is_shared': 'shared', 'is_shared': 'shared',
@ -100,7 +106,7 @@ class CreateAddressScope(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_address_scope(**attrs) obj = client.create_address_scope(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -289,6 +295,6 @@ class ShowAddressScope(command.ShowOne):
parsed_args.address_scope, parsed_args.address_scope,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)

View File

@ -13,6 +13,7 @@
"""IP Floating action implementations""" """IP Floating action implementations"""
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import utils from osc_lib import utils
@ -24,6 +25,7 @@ from openstackclient.network.v2 import _tag
_formatters = { _formatters = {
'location': format_columns.DictColumn,
'port_details': utils.format_dict, 'port_details': utils.format_dict,
} }

View File

@ -21,7 +21,9 @@ from openstackclient.i18n import _
from openstackclient.identity import common as identity_common from openstackclient.identity import common as identity_common
from openstackclient.network import sdk_utils from openstackclient.network import sdk_utils
_formatters = { _formatters = {
'location': format_columns.DictColumn,
'subnet_ip_availability': format_columns.ListDictColumn, 'subnet_ip_availability': format_columns.ListDictColumn,
} }

View File

@ -40,6 +40,7 @@ _formatters = {
'subnet_ids': format_columns.ListColumn, 'subnet_ids': format_columns.ListColumn,
'admin_state_up': AdminStateColumn, 'admin_state_up': AdminStateColumn,
'is_admin_state_up': AdminStateColumn, 'is_admin_state_up': AdminStateColumn,
'location': format_columns.DictColumn,
'router:external': RouterExternalColumn, 'router:external': RouterExternalColumn,
'is_router_external': RouterExternalColumn, 'is_router_external': RouterExternalColumn,
'availability_zones': format_columns.ListColumn, 'availability_zones': format_columns.ListColumn,

View File

@ -43,6 +43,7 @@ _formatters = {
'alive': AliveColumn, 'alive': AliveColumn,
'admin_state_up': AdminStateColumn, 'admin_state_up': AdminStateColumn,
'is_admin_state_up': AdminStateColumn, 'is_admin_state_up': AdminStateColumn,
'location': format_columns.DictColumn,
'configurations': format_columns.DictColumn, 'configurations': format_columns.DictColumn,
} }

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import utils from osc_lib import utils
@ -25,6 +26,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'tenant_id': 'project_id', 'tenant_id': 'project_id',
@ -93,16 +99,17 @@ class CreateAutoAllocatedTopology(command.ShowOne):
obj = client.validate_auto_allocated_topology(parsed_args.project) obj = client.validate_auto_allocated_topology(parsed_args.project)
columns = _format_check_resource_columns() columns = _format_check_resource_columns()
data = utils.get_item_properties(_format_check_resource(obj), data = utils.get_item_properties(
_format_check_resource(obj),
columns, columns,
formatters={}) formatters=_formatters,
)
return (columns, data) return (columns, data)
def get_topology(self, client, parsed_args): def get_topology(self, client, parsed_args):
obj = client.get_auto_allocated_topology(parsed_args.project) obj = client.get_auto_allocated_topology(parsed_args.project)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
def take_action(self, parsed_args): def take_action(self, parsed_args):

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'is_enabled': 'enabled', 'is_enabled': 'enabled',
@ -136,7 +142,7 @@ class CreateNetworkFlavor(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_flavor(**attrs) obj = client.create_flavor(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -300,5 +306,5 @@ class ShowNetworkFlavor(command.ShowOne):
client = self.app.client_manager.network client = self.app.client_manager.network
obj = client.find_flavor(parsed_args.flavor, ignore_missing=False) obj = client.find_flavor(parsed_args.flavor, ignore_missing=False)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -13,6 +13,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -25,6 +26,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'is_enabled': 'enabled', 'is_enabled': 'enabled',
@ -110,7 +116,7 @@ class CreateNetworkFlavorProfile(command.ShowOne):
obj = client.create_service_profile(**attrs) obj = client.create_service_profile(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -246,5 +252,5 @@ class ShowNetworkFlavorProfile(command.ShowOne):
obj = client.find_service_profile(parsed_args.flavor_profile, obj = client.find_service_profile(parsed_args.flavor_profile,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -26,6 +27,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'is_shared': 'shared', 'is_shared': 'shared',
@ -102,7 +108,7 @@ class CreateMeter(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_metering_label(**attrs) obj = client.create_metering_label(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -186,5 +192,5 @@ class ShowMeter(command.ShowOne):
obj = client.find_metering_label(parsed_args.meter, obj = client.find_metering_label(parsed_args.meter,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -26,6 +27,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'tenant_id': 'project_id', 'tenant_id': 'project_id',
@ -116,7 +122,7 @@ class CreateMeterRule(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_metering_label_rule(**attrs) obj = client.create_metering_label_rule(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -199,5 +205,5 @@ class ShowMeterRule(command.ShowOne):
obj = client.find_metering_label_rule(parsed_args.meter_rule_id, obj = client.find_metering_label_rule(parsed_args.meter_rule_id,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'is_shared': 'shared', 'is_shared': 'shared',
@ -119,7 +125,7 @@ class CreateNetworkQosPolicy(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_qos_policy(**attrs) obj = client.create_qos_policy(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={}) data = utils.get_item_properties(obj, columns, formatters=_formatters)
return (display_columns, data) return (display_columns, data)
@ -279,5 +285,5 @@ class ShowNetworkQosPolicy(command.ShowOne):
obj = client.find_qos_policy(parsed_args.policy, obj = client.find_qos_policy(parsed_args.policy,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)

View File

@ -15,6 +15,7 @@
import itertools import itertools
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -46,6 +47,11 @@ ACTION_SET = 'update'
ACTION_SHOW = 'get' ACTION_SHOW = 'get'
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'tenant_id': 'project_id', 'tenant_id': 'project_id',
@ -208,7 +214,7 @@ class CreateNetworkQosRule(command.ShowOne):
msg = (_('Failed to create Network QoS rule: %(e)s') % {'e': e}) msg = (_('Failed to create Network QoS rule: %(e)s') % {'e': e})
raise exceptions.CommandError(msg) raise exceptions.CommandError(msg)
display_columns, columns = _get_columns(obj) 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 return display_columns, data
@ -358,5 +364,5 @@ class ShowNetworkQosRule(command.ShowOne):
{'rule': rule_id, 'e': e}) {'rule': rule_id, 'e': e})
raise exceptions.CommandError(msg) raise exceptions.CommandError(msg)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import utils from osc_lib import utils
@ -20,6 +21,11 @@ from openstackclient.i18n import _
from openstackclient.network import sdk_utils from openstackclient.network import sdk_utils
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
"type": "rule_type_name", "type": "rule_type_name",
@ -65,5 +71,5 @@ class ShowNetworkQosRuleType(command.ShowOne):
client = self.app.client_manager.network client = self.app.client_manager.network
obj = client.get_qos_rule_type(parsed_args.rule_type) obj = client.get_qos_rule_type(parsed_args.rule_type)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
column_map = { column_map = {
'target_tenant': 'target_project_id', 'target_tenant': 'target_project_id',
@ -136,7 +142,7 @@ class CreateNetworkRBAC(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args) attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_rbac_policy(**attrs) obj = client.create_rbac_policy(**attrs)
display_columns, columns = _get_columns(obj) 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 return display_columns, data
@ -293,5 +299,5 @@ class ShowNetworkRBAC(command.ShowOne):
obj = client.find_rbac_policy(parsed_args.rbac_policy, obj = client.find_rbac_policy(parsed_args.rbac_policy,
ignore_missing=False) ignore_missing=False)
display_columns, columns = _get_columns(obj) 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 return display_columns, data

View File

@ -15,6 +15,7 @@
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -26,6 +27,11 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
return sdk_utils.get_osc_show_columns_for_sdk_resource(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 attrs['segmentation_id'] = parsed_args.segment
obj = client.create_segment(**attrs) obj = client.create_segment(**attrs)
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)
@ -242,5 +248,5 @@ class ShowNetworkSegment(command.ShowOne):
ignore_missing=False ignore_missing=False
) )
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)

View File

@ -19,6 +19,7 @@
import itertools import itertools
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -31,6 +32,10 @@ from openstackclient.network import sdk_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _get_columns(item): def _get_columns(item):
return sdk_utils.get_osc_show_columns_for_sdk_resource(item, {}) return sdk_utils.get_osc_show_columns_for_sdk_resource(item, {})
@ -212,7 +217,7 @@ class CreateNetworkSegmentRange(command.ShowOne):
attrs['physical_network'] = parsed_args.physical_network attrs['physical_network'] = parsed_args.physical_network
obj = network_client.create_network_segment_range(**attrs) obj = network_client.create_network_segment_range(**attrs)
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns) data = utils.get_item_properties(obj, columns, formatters=_formatters)
data = _update_additional_fields_from_props(columns, props=data) data = _update_additional_fields_from_props(columns, props=data)
return (display_columns, data) return (display_columns, data)
@ -451,6 +456,6 @@ class ShowNetworkSegmentRange(command.ShowOne):
ignore_missing=False ignore_missing=False
) )
display_columns, columns = _get_columns(obj) display_columns, columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns) data = utils.get_item_properties(obj, columns, formatters=_formatters)
data = _update_additional_fields_from_props(columns, props=data) data = _update_additional_fields_from_props(columns, props=data)
return (display_columns, data) return (display_columns, data)

View File

@ -51,6 +51,7 @@ _formatters = {
'dns_assignment': format_columns.ListDictColumn, 'dns_assignment': format_columns.ListDictColumn,
'extra_dhcp_opts': format_columns.ListDictColumn, 'extra_dhcp_opts': format_columns.ListDictColumn,
'fixed_ips': format_columns.ListDictColumn, 'fixed_ips': format_columns.ListDictColumn,
'location': format_columns.DictColumn,
'security_group_ids': format_columns.ListColumn, 'security_group_ids': format_columns.ListColumn,
'tags': format_columns.ListColumn, 'tags': format_columns.ListColumn,
} }

View File

@ -61,6 +61,7 @@ _formatters = {
'external_gateway_info': RouterInfoColumn, 'external_gateway_info': RouterInfoColumn,
'availability_zones': format_columns.ListColumn, 'availability_zones': format_columns.ListColumn,
'availability_zone_hints': format_columns.ListColumn, 'availability_zone_hints': format_columns.ListColumn,
'location': format_columns.DictColumn,
'routes': RoutesColumn, 'routes': RoutesColumn,
'tags': format_columns.ListColumn, 'tags': format_columns.ListColumn,
} }

View File

@ -16,6 +16,7 @@
import argparse import argparse
from cliff import columns as cliff_columns from cliff import columns as cliff_columns
from osc_lib.cli import format_columns
from osc_lib.command import command from osc_lib.command import command
from osc_lib import utils from osc_lib import utils
import six import six
@ -77,11 +78,13 @@ class ComputeSecurityGroupRulesColumn(cliff_columns.FormattableColumn):
_formatters_network = { _formatters_network = {
'location': format_columns.DictColumn,
'security_group_rules': NetworkSecurityGroupRulesColumn, 'security_group_rules': NetworkSecurityGroupRulesColumn,
} }
_formatters_compute = { _formatters_compute = {
'location': format_columns.DictColumn,
'rules': ComputeSecurityGroupRulesColumn, 'rules': ComputeSecurityGroupRulesColumn,
} }

View File

@ -16,6 +16,7 @@
import argparse import argparse
import logging import logging
from osc_lib.cli import format_columns
from osc_lib.cli import parseractions from osc_lib.cli import parseractions
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
@ -31,6 +32,11 @@ from openstackclient.network import utils as network_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
_formatters = {
'location': format_columns.DictColumn,
}
def _format_security_group_rule_show(obj): def _format_security_group_rule_show(obj):
data = network_utils.transform_compute_security_group_rule(obj) data = network_utils.transform_compute_security_group_rule(obj)
return zip(*sorted(six.iteritems(data))) return zip(*sorted(six.iteritems(data)))
@ -337,7 +343,7 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
# Create and show the security group rule. # Create and show the security group rule.
obj = client.create_security_group_rule(**attrs) obj = client.create_security_group_rule(**attrs)
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)
def take_action_compute(self, client, parsed_args): def take_action_compute(self, client, parsed_args):
@ -596,7 +602,7 @@ class ShowSecurityGroupRule(common.NetworkAndComputeShowOne):
if not obj['remote_ip_prefix']: if not obj['remote_ip_prefix']:
obj['remote_ip_prefix'] = _format_remote_ip_prefix(obj) obj['remote_ip_prefix'] = _format_remote_ip_prefix(obj)
display_columns, columns = _get_columns(obj) 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) return (display_columns, data)
def take_action_compute(self, client, parsed_args): def take_action_compute(self, client, parsed_args):

View File

@ -61,6 +61,7 @@ _formatters = {
'allocation_pools': AllocationPoolsColumn, 'allocation_pools': AllocationPoolsColumn,
'dns_nameservers': format_columns.ListColumn, 'dns_nameservers': format_columns.ListColumn,
'host_routes': HostRoutesColumn, 'host_routes': HostRoutesColumn,
'location': format_columns.DictColumn,
'service_types': format_columns.ListColumn, 'service_types': format_columns.ListColumn,
'tags': format_columns.ListColumn, 'tags': format_columns.ListColumn,
} }

View File

@ -42,6 +42,7 @@ def _get_columns(item):
_formatters = { _formatters = {
'location': format_columns.DictColumn,
'prefixes': format_columns.ListColumn, 'prefixes': format_columns.ListColumn,
'tags': format_columns.ListColumn, 'tags': format_columns.ListColumn,
} }