Fix network router type display

The OpenStack SDK maps the network "router:external" field to
"is_router_external". However, OSC was using the incorrect
mapping, "router_external".  This caused OSC to display router
type as "Internal" for all networks.

Change-Id: Ifcd1349ab7c5881baee751936d076bf6aa058852
Closes-Bug: #1572228
This commit is contained in:
Richard Theis 2016-04-19 14:42:01 -05:00
parent 461a203f2d
commit 9f3fa5ee3b
4 changed files with 18 additions and 15 deletions

View File

@ -32,7 +32,7 @@ def _format_router_external(item):
_formatters = { _formatters = {
'subnets': utils.format_list, 'subnets': utils.format_list,
'admin_state_up': _format_admin_state, 'admin_state_up': _format_admin_state,
'router_external': _format_router_external, 'router:external': _format_router_external,
'availability_zones': utils.format_list, 'availability_zones': utils.format_list,
'availability_zone_hints': utils.format_list, 'availability_zone_hints': utils.format_list,
} }
@ -43,9 +43,6 @@ def _get_columns(item):
if 'tenant_id' in columns: if 'tenant_id' in columns:
columns.remove('tenant_id') columns.remove('tenant_id')
columns.append('project_id') columns.append('project_id')
if 'router:external' in columns:
columns.remove('router:external')
columns.append('router_external')
return tuple(sorted(columns)) return tuple(sorted(columns))
@ -290,7 +287,7 @@ class ListNetwork(common.NetworkAndComputeLister):
'shared', 'shared',
'subnets', 'subnets',
'provider_network_type', 'provider_network_type',
'router_external', 'router:external',
'availability_zones', 'availability_zones',
) )
column_headers = ( column_headers = (

View File

@ -166,8 +166,7 @@ class FakeNetwork(object):
:param Dictionary attrs: :param Dictionary attrs:
A dictionary with all attributes A dictionary with all attributes
:return: :return:
A FakeResource object, with id, name, admin_state_up, A FakeResource object, with id, name, etc.
router_external, status, subnets, tenant_id
""" """
attrs = attrs or {} attrs = attrs or {}
@ -181,7 +180,7 @@ class FakeNetwork(object):
'shared': False, 'shared': False,
'subnets': ['a', 'b'], 'subnets': ['a', 'b'],
'provider_network_type': 'vlan', 'provider_network_type': 'vlan',
'router_external': True, 'router:external': True,
'availability_zones': [], 'availability_zones': [],
'availability_zone_hints': [], 'availability_zone_hints': [],
'is_default': False, 'is_default': False,
@ -195,6 +194,7 @@ class FakeNetwork(object):
# Set attributes with special mapping in OpenStack SDK. # Set attributes with special mapping in OpenStack SDK.
network.project_id = network_attrs['tenant_id'] network.project_id = network_attrs['tenant_id']
network.is_router_external = network_attrs['router:external']
return network return network

View File

@ -55,7 +55,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'name', 'name',
'project_id', 'project_id',
'provider_network_type', 'provider_network_type',
'router_external', 'router:external',
'shared', 'shared',
'status', 'status',
'subnets', 'subnets',
@ -70,7 +70,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
_network.name, _network.name,
_network.project_id, _network.project_id,
_network.provider_network_type, _network.provider_network_type,
network._format_router_external(_network.router_external), network._format_router_external(_network.is_router_external),
_network.shared, _network.shared,
_network.status, _network.status,
utils.format_list(_network.subnets), utils.format_list(_network.subnets),
@ -224,7 +224,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
'name', 'name',
'project_id', 'project_id',
'provider_network_type', 'provider_network_type',
'router_external', 'router:external',
'shared', 'shared',
'status', 'status',
'subnets', 'subnets',
@ -239,7 +239,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
_network.name, _network.name,
_network.project_id, _network.project_id,
_network.provider_network_type, _network.provider_network_type,
network._format_router_external(_network.router_external), network._format_router_external(_network.is_router_external),
_network.shared, _network.shared,
_network.status, _network.status,
utils.format_list(_network.subnets), utils.format_list(_network.subnets),
@ -391,7 +391,7 @@ class TestListNetwork(TestNetwork):
net.shared, net.shared,
utils.format_list(net.subnets), utils.format_list(net.subnets),
net.provider_network_type, net.provider_network_type,
network._format_router_external(net.router_external), network._format_router_external(net.is_router_external),
utils.format_list(net.availability_zones), utils.format_list(net.availability_zones),
)) ))
@ -566,7 +566,7 @@ class TestShowNetwork(TestNetwork):
'name', 'name',
'project_id', 'project_id',
'provider_network_type', 'provider_network_type',
'router_external', 'router:external',
'shared', 'shared',
'status', 'status',
'subnets', 'subnets',
@ -581,7 +581,7 @@ class TestShowNetwork(TestNetwork):
_network.name, _network.name,
_network.project_id, _network.project_id,
_network.provider_network_type, _network.provider_network_type,
network._format_router_external(_network.router_external), network._format_router_external(_network.is_router_external),
_network.shared, _network.shared,
_network.status, _network.status,
utils.format_list(_network.subnets), utils.format_list(_network.subnets),

View File

@ -0,0 +1,6 @@
---
fixes:
- Fixed ``network create``, ``network show`` and ``network list``
commands to correctly display the router type in the
``router:external`` and ``Router Type`` columns.
[Bug `1572228 <https://bugs.launchpad.net/bugs/1572228>`_]