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
This commit is contained in:
Choe, Cheng-Dae 2016-10-08 02:50:25 +09:00
parent 762f2f2c34
commit 2bbb482106
2 changed files with 3 additions and 4 deletions

View file

@ -520,12 +520,11 @@ class UnsetRouter(command.Command):
if parsed_args.routes:
try:
for route in parsed_args.routes:
route['nexthop'] = route.pop('gateway')
tmp_routes.remove(route)
except ValueError:
msg = (_("Router does not contain route %s") % route)
raise exceptions.CommandError(msg)
for route in tmp_routes:
route['nexthop'] = route.pop('gateway')
attrs['routes'] = tmp_routes
if attrs:
client.update_router(obj, **attrs)

View file

@ -773,9 +773,9 @@ class TestUnsetRouter(TestRouter):
super(TestUnsetRouter, self).setUp()
self._testrouter = network_fakes.FakeRouter.create_one_router(
{'routes': [{"destination": "192.168.101.1/24",
"gateway": "172.24.4.3"},
"nexthop": "172.24.4.3"},
{"destination": "192.168.101.2/24",
"gateway": "172.24.4.3"}], })
"nexthop": "172.24.4.3"}], })
self.fake_subnet = network_fakes.FakeSubnet.create_one_subnet()
self.network.find_router = mock.Mock(return_value=self._testrouter)
self.network.update_router = mock.Mock(return_value=None)