Add support for clearing router gateway
This patch adds the support to clear the gateway information from a router. Change-Id: I446c556750f080a6fc21fea8f531fd71838d648a Implements: blueprint neutron-client-advanced-router Partially-Implements: blueprint network-commands-options
This commit is contained in:
parent
e51a2b3b17
commit
4a5bf8d2a5
@ -318,6 +318,7 @@ Unset router properties
|
||||
|
||||
os router unset
|
||||
[--route destination=<subnet>,gateway=<ip-address>]
|
||||
[--external-gateway]
|
||||
<router>
|
||||
|
||||
.. option:: --route destination=<subnet>,gateway=<ip-address>
|
||||
@ -327,6 +328,10 @@ Unset router properties
|
||||
gateway: nexthop IP address
|
||||
(repeat option to unset multiple routes)
|
||||
|
||||
.. option:: --external-gateway
|
||||
|
||||
Remove external gateway information from the router
|
||||
|
||||
.. _router_unset-router:
|
||||
.. describe:: <router>
|
||||
|
||||
|
@ -621,6 +621,11 @@ class UnsetRouter(command.Command):
|
||||
"destination: destination subnet (in CIDR notation) "
|
||||
"gateway: nexthop IP address "
|
||||
"(repeat option to unset multiple routes)"))
|
||||
parser.add_argument(
|
||||
'--external-gateway',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_("Remove external gateway information from the router"))
|
||||
parser.add_argument(
|
||||
'router',
|
||||
metavar="<router>",
|
||||
@ -642,5 +647,7 @@ class UnsetRouter(command.Command):
|
||||
msg = (_("Router does not contain route %s") % route)
|
||||
raise exceptions.CommandError(msg)
|
||||
attrs['routes'] = tmp_routes
|
||||
if parsed_args.external_gateway:
|
||||
attrs['external_gateway_info'] = {}
|
||||
if attrs:
|
||||
client.update_router(obj, **attrs)
|
||||
|
@ -1021,3 +1021,16 @@ class TestUnsetRouter(TestRouter):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
self.cmd.take_action, parsed_args)
|
||||
|
||||
def test_unset_router_external_gateway(self):
|
||||
arglist = [
|
||||
'--external-gateway',
|
||||
self._testrouter.name,
|
||||
]
|
||||
verifylist = [('external_gateway', True)]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
attrs = {'external_gateway_info': {}}
|
||||
self.network.update_router.assert_called_once_with(
|
||||
self._testrouter, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
@ -3,5 +3,6 @@ features:
|
||||
- |
|
||||
Add support for setting the gateway information in a router,
|
||||
by introducing the new option ``--external-gateway`` in
|
||||
``router set`` CLI.
|
||||
``router set`` command and clearing the gateway information in a router
|
||||
by introducing ``--external-gateway`` option in ``router unset`` command.
|
||||
[ Blueprint `neutron-client-advanced-router <https://blueprints.launchpad.net/python-openstackclient/+spec/neutron-client-advanced-router>`_]
|
||||
|
Loading…
Reference in New Issue
Block a user