Cleanup veth-pairs in default netns for functional tests

Today, veth-pairs created by the VethFixture of the net_helpers class
are not cleanup on teardown. This is solved by this patch.

Conflicts:
	neutron/tests/common/net_helpers.py

Change-Id: I0a969e31e6694d74a9af6ada4e4e707c6332ffeb
Closes-Bug: #1522710
(cherry picked from commit 6ec16458fe)
This commit is contained in:
Andreas Scheuring 2015-12-04 08:35:28 +01:00 committed by Arie Bregman
parent cc6b16558e
commit 8bde9c407a
1 changed files with 9 additions and 7 deletions

View File

@ -419,13 +419,15 @@ class VethFixture(fixtures.Fixture):
def destroy(self):
for port in self.ports:
ip_wrapper = ip_lib.IPWrapper(port.namespace)
try:
ip_wrapper.del_veth(port.name)
break
except RuntimeError:
# NOTE(cbrandily): It seems a veth is automagically deleted
# when a namespace owning a veth endpoint is deleted.
pass
if (ip_wrapper.netns.exists(port.namespace) or
port.namespace is None):
try:
ip_wrapper.del_veth(port.name)
break
except RuntimeError:
# NOTE(cbrandily): It seems a veth is automagically deleted
# when a namespace owning a veth endpoint is deleted.
pass
@staticmethod
def get_peer_name(name):