Skip to content

Commit 2bbb482

Browse files
committed
Fix router unset --route option
Fix the "--route" option one the "os route unset" command. The option did not convert gateway to nexthop which results "Router does not contain route" error. Change-Id: Ia57bc7ea77ad7c6030535180a6ce42b4928c9e56 Closes-Bug: 1631471
1 parent 762f2f2 commit 2bbb482

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

openstackclient/network/v2/router.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,11 @@ def take_action(self, parsed_args):
520520
if parsed_args.routes:
521521
try:
522522
for route in parsed_args.routes:
523+
route['nexthop'] = route.pop('gateway')
523524
tmp_routes.remove(route)
524525
except ValueError:
525526
msg = (_("Router does not contain route %s") % route)
526527
raise exceptions.CommandError(msg)
527-
for route in tmp_routes:
528-
route['nexthop'] = route.pop('gateway')
529528
attrs['routes'] = tmp_routes
530529
if attrs:
531530
client.update_router(obj, **attrs)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,9 @@ def setUp(self):
773773
super(TestUnsetRouter, self).setUp()
774774
self._testrouter = network_fakes.FakeRouter.create_one_router(
775775
{'routes': [{"destination": "192.168.101.1/24",
776-
"gateway": "172.24.4.3"},
776+
"nexthop": "172.24.4.3"},
777777
{"destination": "192.168.101.2/24",
778-
"gateway": "172.24.4.3"}], })
778+
"nexthop": "172.24.4.3"}], })
779779
self.fake_subnet = network_fakes.FakeSubnet.create_one_subnet()
780780
self.network.find_router = mock.Mock(return_value=self._testrouter)
781781
self.network.update_router = mock.Mock(return_value=None)

0 commit comments

Comments
 (0)