summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReedip <reedip14@gmail.com>2016-11-29 07:18:47 -0500
committerReedip <reedip14@gmail.com>2016-12-19 17:30:19 -0500
commit4a5bf8d2a58fde1d6cbbd2bb27c3eb6fabe59c3a (patch)
tree267e9d4f4c91f736e3f2950f42e8e687e0c1052d
parente51a2b3b171f3c72a715bee3ad99c0f88efa3010 (diff)
downloadpython-openstackclient-4a5bf8d2a58fde1d6cbbd2bb27c3eb6fabe59c3a.tar.gz
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
-rw-r--r--doc/source/command-objects/router.rst5
-rw-r--r--openstackclient/network/v2/router.py7
-rw-r--r--openstackclient/tests/unit/network/v2/test_router.py13
-rw-r--r--releasenotes/notes/router-gateway-set-01d9c7ffe4461daf.yaml3
4 files changed, 27 insertions, 1 deletions
diff --git a/doc/source/command-objects/router.rst b/doc/source/command-objects/router.rst
index 16a8258d..ee894661 100644
--- a/doc/source/command-objects/router.rst
+++ b/doc/source/command-objects/router.rst
@@ -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>
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
@@ -622,6 +622,11 @@ class UnsetRouter(command.Command):
"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>",
help=_("Router to modify (name or ID)")
@@ -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)
diff --git a/releasenotes/notes/router-gateway-set-01d9c7ffe4461daf.yaml b/releasenotes/notes/router-gateway-set-01d9c7ffe4461daf.yaml
index dec9d096..9e3f1959 100644
--- a/releasenotes/notes/router-gateway-set-01d9c7ffe4461daf.yaml
+++ b/releasenotes/notes/router-gateway-set-01d9c7ffe4461daf.yaml
@@ -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>`_]