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 87488f345c
)
Conflicts:
neutron/agent/linux/ip_lib.py
neutron/tests/unit/agent/linux/test_ip_lib.py
Change-Id: I401b242cc86ba1de7a20943d8b0340e0f0005ba3
This commit is contained in:
parent
b298ba14a4
commit
c4041daa23
|
@ -829,6 +829,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]
|
||||
|
|
|
@ -1002,6 +1002,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],
|
||||
|
|
Loading…
Reference in New Issue