From 0d33e60261bc97214fbb3aead6c5e30cae1b88a4 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Mon, 19 Aug 2019 23:42:32 +0200
Subject: dummy: T1580: Python: support {add,remove}_interface in
 vyos.configinterface

---
 python/vyos/configinterface.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

(limited to 'python')

diff --git a/python/vyos/configinterface.py b/python/vyos/configinterface.py
index 0f5b0842c..843d1c739 100644
--- a/python/vyos/configinterface.py
+++ b/python/vyos/configinterface.py
@@ -151,3 +151,24 @@ def remove_interface_address(intf, addr):
         raise ConfigError('{} is not a valid interface address'.format(addr))
 
     pass
+
+def remove_interface(ifname):
+    """
+    Remove given interface from operating system, e.g. 'dum0'
+    """
+
+    if os.path.isdir('/sys/class/net/' + ifname):
+        os.system('ip link delete "{}"'.format(ifname))
+
+    pass
+
+def add_interface(type, ifname):
+    """
+    Add given interface to operating system, e.g. add 'dummy' interface with
+    name 'dum0'
+    """
+
+    if not os.path.isdir('/sys/class/net/' + ifname):
+        os.system('ip link add "{}" type "{}"'.format(ifname, type))
+
+    pass
-- 
cgit v1.2.3