summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSwaminathan Vasudevan <swaminathan.vasudevan@hpe.com>2016-08-01 08:54:40 -0700
committerSwaminathan Vasudevan <swaminathan.vasudevan@hpe.com>2016-08-30 14:12:26 -0700
commit9cd2dfceae43c68e17b95beec697cde12f718a21 (patch)
tree640f6f5e4ae6cef89c726c6207b1852c978e618e
parent120a643a374b5bb741f2273d33f55d70bd7ec3fa (diff)
downloadneutron-9cd2dfceae43c68e17b95beec697cde12f718a21.tar.gz
Add flush command to iproute in ip_lib
IP route flush command to support flush the route entries. Closes-Bug: #1611513 (cherry picked from commit 87488f345c47d587e432206b2f7289a727e7e528) Conflicts: neutron/agent/linux/ip_lib.py neutron/tests/unit/agent/linux/test_ip_lib.py Change-Id: I401b242cc86ba1de7a20943d8b0340e0f0005ba3
-rw-r--r--neutron/agent/linux/ip_lib.py7
-rw-r--r--neutron/tests/unit/agent/linux/test_ip_lib.py4
2 files changed, 11 insertions, 0 deletions
diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py
index 7d7962366b..115686f0d4 100644
--- a/neutron/agent/linux/ip_lib.py
+++ b/neutron/agent/linux/ip_lib.py
@@ -800,6 +800,13 @@ class IpRouteCommand(IpDeviceCommandBase):
'proto', 'kernel',
'dev', device))
+ def flush(self, ip_version, table=None, **kwargs):
+ args = ['flush']
+ args += self._table_args(table)
+ for k, v in kwargs.items():
+ args += [k, v]
+ self._as_root([ip_version], tuple(args))
+
def add_route(self, cidr, via=None, table=None, **kwargs):
ip_version = get_ip_version(cidr)
args = ['replace', cidr]
diff --git a/neutron/tests/unit/agent/linux/test_ip_lib.py b/neutron/tests/unit/agent/linux/test_ip_lib.py
index 3e1d351d42..a33f36e5f7 100644
--- a/neutron/tests/unit/agent/linux/test_ip_lib.py
+++ b/neutron/tests/unit/agent/linux/test_ip_lib.py
@@ -982,6 +982,10 @@ class TestIpRouteCommand(TestIPCmdBase):
# Check two calls - device get and subnet get
self.assertEqual(len(self.parent._run.mock_calls), 2)
+ def test_flush_route_table(self):
+ self.route_cmd.flush(self.ip_version, self.table)
+ self._assert_sudo([self.ip_version], ('flush', 'table', self.table))
+
def test_add_route(self):
self.route_cmd.add_route(self.cidr, self.ip, self.table)
self._assert_sudo([self.ip_version],