Commit 1bd744d5 authored by Yonghong Song's avatar Yonghong Song

clean up potential conflict veth before creating new one in create_ns

Signed-off-by: default avatarYonghong Song <yhs@plumgrid.com>
parent 02bf6819
......@@ -54,7 +54,7 @@ try:
for p in sim.processes: p.communicate(b"\n")
except:
if "sim" in locals():
for p in sim.processes: p.kill(); p.wait()
for p in sim.processes: p.kill(); p.wait(); p.release()
finally:
if "br-fabric" in ipdb.interfaces: ipdb.interfaces["br-fabric"].remove().commit()
if "sim" in locals(): sim.release()
......
import os
import subprocess
import pyroute2
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
......@@ -46,6 +47,9 @@ class Simulation(object):
# move half of veth into namespace
v.net_ns_fd = ns_ipdb.nl.netns
else:
# delete the potentially leaf-over veth interfaces
subprocess.call(["ip", "link", "del", "%sa" % ifc_base_name],
stderr=open(os.devnull, 'w'))
try:
out_ifc = self.ipdb.create(ifname="%sa" % ifc_base_name, kind="veth",
peer="%sb" % ifc_base_name).commit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment