diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-08-19 23:42:32 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-08-19 23:45:55 +0200 |
commit | 0d33e60261bc97214fbb3aead6c5e30cae1b88a4 (patch) | |
tree | 14d2f1407de315deff84ceb8d5a2f7a978e91e96 /python/vyos | |
parent | 5d858f0e6ad05b032c88c88a08c15d0876c44e8b (diff) | |
download | vyos-1x-0d33e60261bc97214fbb3aead6c5e30cae1b88a4.tar.gz vyos-1x-0d33e60261bc97214fbb3aead6c5e30cae1b88a4.zip |
dummy: T1580: Python: support {add,remove}_interface in vyos.configinterface
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/configinterface.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 |