Merge "Format location columns in network commands"
This commit is contained in:
commit
678167a6bf
@ -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
|
||||
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'is_shared': 'shared',
|
||||
@ -100,7 +106,7 @@ class CreateAddressScope(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_address_scope(**attrs)
|
||||
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)
|
||||
|
||||
@ -289,6 +295,6 @@ class ShowAddressScope(command.ShowOne):
|
||||
parsed_args.address_scope,
|
||||
ignore_missing=False)
|
||||
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)
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
"""IP Floating action implementations"""
|
||||
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
@ -24,6 +25,7 @@ from openstackclient.network.v2 import _tag
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
'port_details': utils.format_dict,
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,9 @@ from openstackclient.i18n import _
|
||||
from openstackclient.identity import common as identity_common
|
||||
from openstackclient.network import sdk_utils
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
'subnet_ip_availability': format_columns.ListDictColumn,
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ _formatters = {
|
||||
'subnet_ids': format_columns.ListColumn,
|
||||
'admin_state_up': AdminStateColumn,
|
||||
'is_admin_state_up': AdminStateColumn,
|
||||
'location': format_columns.DictColumn,
|
||||
'router:external': RouterExternalColumn,
|
||||
'is_router_external': RouterExternalColumn,
|
||||
'availability_zones': format_columns.ListColumn,
|
||||
|
@ -43,6 +43,7 @@ _formatters = {
|
||||
'alive': AliveColumn,
|
||||
'admin_state_up': AdminStateColumn,
|
||||
'is_admin_state_up': AdminStateColumn,
|
||||
'location': format_columns.DictColumn,
|
||||
'configurations': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
@ -25,6 +26,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'tenant_id': 'project_id',
|
||||
@ -93,16 +99,17 @@ class CreateAutoAllocatedTopology(command.ShowOne):
|
||||
obj = client.validate_auto_allocated_topology(parsed_args.project)
|
||||
|
||||
columns = _format_check_resource_columns()
|
||||
data = utils.get_item_properties(_format_check_resource(obj),
|
||||
columns,
|
||||
formatters={})
|
||||
|
||||
data = utils.get_item_properties(
|
||||
_format_check_resource(obj),
|
||||
columns,
|
||||
formatters=_formatters,
|
||||
)
|
||||
return (columns, data)
|
||||
|
||||
def get_topology(self, client, parsed_args):
|
||||
obj = client.get_auto_allocated_topology(parsed_args.project)
|
||||
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)
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -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
|
||||
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'is_enabled': 'enabled',
|
||||
@ -136,7 +142,7 @@ class CreateNetworkFlavor(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_flavor(**attrs)
|
||||
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)
|
||||
|
||||
@ -300,5 +306,5 @@ class ShowNetworkFlavor(command.ShowOne):
|
||||
client = self.app.client_manager.network
|
||||
obj = client.find_flavor(parsed_args.flavor, 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
|
||||
|
@ -13,6 +13,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
|
||||
@ -25,6 +26,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'is_enabled': 'enabled',
|
||||
@ -110,7 +116,7 @@ class CreateNetworkFlavorProfile(command.ShowOne):
|
||||
|
||||
obj = client.create_service_profile(**attrs)
|
||||
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)
|
||||
|
||||
@ -246,5 +252,5 @@ class ShowNetworkFlavorProfile(command.ShowOne):
|
||||
obj = client.find_service_profile(parsed_args.flavor_profile,
|
||||
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)
|
||||
|
@ -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):
|
||||
column_map = {
|
||||
'is_shared': 'shared',
|
||||
@ -102,7 +108,7 @@ class CreateMeter(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_metering_label(**attrs)
|
||||
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)
|
||||
|
||||
@ -186,5 +192,5 @@ class ShowMeter(command.ShowOne):
|
||||
obj = client.find_metering_label(parsed_args.meter,
|
||||
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
|
||||
|
@ -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):
|
||||
column_map = {
|
||||
'tenant_id': 'project_id',
|
||||
@ -116,7 +122,7 @@ class CreateMeterRule(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_metering_label_rule(**attrs)
|
||||
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)
|
||||
|
||||
@ -199,5 +205,5 @@ class ShowMeterRule(command.ShowOne):
|
||||
obj = client.find_metering_label_rule(parsed_args.meter_rule_id,
|
||||
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
|
||||
|
@ -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
|
||||
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'is_shared': 'shared',
|
||||
@ -119,7 +125,7 @@ class CreateNetworkQosPolicy(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_qos_policy(**attrs)
|
||||
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)
|
||||
|
||||
|
||||
@ -279,5 +285,5 @@ class ShowNetworkQosPolicy(command.ShowOne):
|
||||
obj = client.find_qos_policy(parsed_args.policy,
|
||||
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)
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import itertools
|
||||
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
@ -46,6 +47,11 @@ ACTION_SET = 'update'
|
||||
ACTION_SHOW = 'get'
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'tenant_id': 'project_id',
|
||||
@ -208,7 +214,7 @@ class CreateNetworkQosRule(command.ShowOne):
|
||||
msg = (_('Failed to create Network QoS rule: %(e)s') % {'e': e})
|
||||
raise exceptions.CommandError(msg)
|
||||
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
|
||||
|
||||
|
||||
@ -358,5 +364,5 @@ class ShowNetworkQosRule(command.ShowOne):
|
||||
{'rule': rule_id, 'e': e})
|
||||
raise exceptions.CommandError(msg)
|
||||
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
|
||||
|
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
@ -20,6 +21,11 @@ from openstackclient.i18n import _
|
||||
from openstackclient.network import sdk_utils
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
"type": "rule_type_name",
|
||||
@ -65,5 +71,5 @@ class ShowNetworkQosRuleType(command.ShowOne):
|
||||
client = self.app.client_manager.network
|
||||
obj = client.get_qos_rule_type(parsed_args.rule_type)
|
||||
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
|
||||
|
@ -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
|
||||
@ -27,6 +28,11 @@ from openstackclient.network import sdk_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _get_columns(item):
|
||||
column_map = {
|
||||
'target_tenant': 'target_project_id',
|
||||
@ -136,7 +142,7 @@ class CreateNetworkRBAC(command.ShowOne):
|
||||
attrs = _get_attrs(self.app.client_manager, parsed_args)
|
||||
obj = client.create_rbac_policy(**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
|
||||
|
||||
|
||||
@ -293,5 +299,5 @@ class ShowNetworkRBAC(command.ShowOne):
|
||||
obj = client.find_rbac_policy(parsed_args.rbac_policy,
|
||||
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
|
||||
|
@ -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)
|
||||
|
@ -19,6 +19,7 @@
|
||||
import itertools
|
||||
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
|
||||
@ -31,6 +32,10 @@ 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, {})
|
||||
@ -212,7 +217,7 @@ class CreateNetworkSegmentRange(command.ShowOne):
|
||||
attrs['physical_network'] = parsed_args.physical_network
|
||||
obj = network_client.create_network_segment_range(**attrs)
|
||||
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)
|
||||
return (display_columns, data)
|
||||
|
||||
@ -451,6 +456,6 @@ class ShowNetworkSegmentRange(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)
|
||||
data = _update_additional_fields_from_props(columns, props=data)
|
||||
return (display_columns, data)
|
||||
|
@ -51,6 +51,7 @@ _formatters = {
|
||||
'dns_assignment': format_columns.ListDictColumn,
|
||||
'extra_dhcp_opts': format_columns.ListDictColumn,
|
||||
'fixed_ips': format_columns.ListDictColumn,
|
||||
'location': format_columns.DictColumn,
|
||||
'security_group_ids': format_columns.ListColumn,
|
||||
'tags': format_columns.ListColumn,
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ _formatters = {
|
||||
'external_gateway_info': RouterInfoColumn,
|
||||
'availability_zones': format_columns.ListColumn,
|
||||
'availability_zone_hints': format_columns.ListColumn,
|
||||
'location': format_columns.DictColumn,
|
||||
'routes': RoutesColumn,
|
||||
'tags': format_columns.ListColumn,
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
import argparse
|
||||
|
||||
from cliff import columns as cliff_columns
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
@ -77,11 +78,13 @@ class ComputeSecurityGroupRulesColumn(cliff_columns.FormattableColumn):
|
||||
|
||||
|
||||
_formatters_network = {
|
||||
'location': format_columns.DictColumn,
|
||||
'security_group_rules': NetworkSecurityGroupRulesColumn,
|
||||
}
|
||||
|
||||
|
||||
_formatters_compute = {
|
||||
'location': format_columns.DictColumn,
|
||||
'rules': ComputeSecurityGroupRulesColumn,
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from osc_lib.cli import format_columns
|
||||
from osc_lib.cli import parseractions
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
@ -31,6 +32,11 @@ from openstackclient.network import utils as network_utils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
}
|
||||
|
||||
|
||||
def _format_security_group_rule_show(obj):
|
||||
data = network_utils.transform_compute_security_group_rule(obj)
|
||||
return zip(*sorted(six.iteritems(data)))
|
||||
@ -337,7 +343,7 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
|
||||
# Create and show the security group rule.
|
||||
obj = client.create_security_group_rule(**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)
|
||||
|
||||
def take_action_compute(self, client, parsed_args):
|
||||
@ -596,7 +602,7 @@ class ShowSecurityGroupRule(common.NetworkAndComputeShowOne):
|
||||
if not obj['remote_ip_prefix']:
|
||||
obj['remote_ip_prefix'] = _format_remote_ip_prefix(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)
|
||||
|
||||
def take_action_compute(self, client, parsed_args):
|
||||
|
@ -61,6 +61,7 @@ _formatters = {
|
||||
'allocation_pools': AllocationPoolsColumn,
|
||||
'dns_nameservers': format_columns.ListColumn,
|
||||
'host_routes': HostRoutesColumn,
|
||||
'location': format_columns.DictColumn,
|
||||
'service_types': format_columns.ListColumn,
|
||||
'tags': format_columns.ListColumn,
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ def _get_columns(item):
|
||||
|
||||
|
||||
_formatters = {
|
||||
'location': format_columns.DictColumn,
|
||||
'prefixes': format_columns.ListColumn,
|
||||
'tags': format_columns.ListColumn,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user