From 4a5bf8d2a58fde1d6cbbd2bb27c3eb6fabe59c3a Mon Sep 17 00:00:00 2001 From: Reedip Date: Tue, 29 Nov 2016 07:18:47 -0500 Subject: 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 --- openstackclient/network/v2/router.py | 7 +++++++ openstackclient/tests/unit/network/v2/test_router.py | 13 +++++++++++++ 2 files changed, 20 insertions(+) (limited to 'openstackclient') diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index fea294da..45507b53 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -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="", @@ -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) diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py index 9183cb63..a24a34c5 100644 --- a/openstackclient/tests/unit/network/v2/test_router.py +++ b/openstackclient/tests/unit/network/v2/test_router.py @@ -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) -- cgit v1.2.1