Skip to content

Commit 509ca3e

Browse files
author
Édouard Thuleau
committed
Fix router create/show if extraroute not supported
If neutron does not support extraroute l3 extension, the route column formatter fails. Change-Id: I7b89c4f818865073947e0850e86c18d0d2415a51
1 parent 5b3a827 commit 509ca3e

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

openstackclient/network/v2/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def human_readable(self):
4949
class RoutesColumn(cliff_columns.FormattableColumn):
5050
def human_readable(self):
5151
# Map the route keys to match --route option.
52-
for route in self._value:
52+
for route in self._value or []:
5353
if 'nexthop' in route:
5454
route['gateway'] = route.pop('nexthop')
5555
return utils.format_list_of_dicts(self._value)

openstackclient/tests/unit/network/v2/test_router.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,24 @@ def test_show_no_ha_no_distributed(self):
12851285
self.assertNotIn("is_distributed", columns)
12861286
self.assertNotIn("is_ha", columns)
12871287

1288+
def test_show_no_extra_route_extension(self):
1289+
_router = network_fakes.FakeRouter.create_one_router({'routes': None})
1290+
1291+
arglist = [
1292+
_router.name,
1293+
]
1294+
verifylist = [
1295+
('router', _router.name),
1296+
]
1297+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1298+
1299+
with mock.patch.object(
1300+
self.network, "find_router", return_value=_router):
1301+
columns, data = self.cmd.take_action(parsed_args)
1302+
1303+
self.assertIn("routes", columns)
1304+
self.assertIsNone(list(data)[columns.index('routes')].human_readable())
1305+
12881306

12891307
class TestUnsetRouter(TestRouter):
12901308

0 commit comments

Comments
 (0)