summaryrefslogtreecommitdiff
path: root/tests/common/iface.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/iface.py')
-rw-r--r--tests/common/iface.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/common/iface.py b/tests/common/iface.py
new file mode 100644
index 00000000..dbd052ab
--- /dev/null
+++ b/tests/common/iface.py
@@ -0,0 +1,23 @@
+from common import netns
+
+# up interface. if netns is None, then up in global rt. if ok returns 0
+def up(iface, netns_name):
+ command = ["ip", "link", "set", iface, "up"]
+ exit, out, err = netns.exec(netns_name, command)
+ print(
+ "iface.up: iface=%s netns=%s exit=%d out=%s err=%s"
+ % (iface, netns_name, exit, out, err)
+ )
+
+ return exit
+
+
+# delete interface. if netns is None, then up in global rt. if ok returns 0
+def delete(iface, netns_name):
+ exit, out, err = netns.exec(netns_name, ["ip", "link", "delete", iface])
+ print(
+ "iface.delete: iface=%s netns=%s exit=%d out=%s err=%s"
+ % (iface, netns_name, exit, out, err)
+ )
+
+ return exit