Skip to content

Commit e43377b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix router create/show if extraroute not supported"
2 parents f5384ae + 509ca3e commit e43377b

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)