diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-08-19 23:46:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 23:46:19 +0200 |
commit | 246d2dbad9df96ac895e88c9103eefa9f4cf04d7 (patch) | |
tree | 8e67e590dcc9d1709626435d751435e567f9f8b9 /python/vyos/configinterface.py | |
parent | 5d858f0e6ad05b032c88c88a08c15d0876c44e8b (diff) | |
parent | 4bd223a00ee35ff92aff4cb19d08c1c6c9190e10 (diff) | |
download | vyos-1x-246d2dbad9df96ac895e88c9103eefa9f4cf04d7.tar.gz vyos-1x-246d2dbad9df96ac895e88c9103eefa9f4cf04d7.zip |
Merge pull request #109 from c-po/t1580-dummy
T1580 dummy
Diffstat (limited to 'python/vyos/configinterface.py')
-rw-r--r-- | python/vyos/configinterface.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/python/vyos/configinterface.py b/python/vyos/configinterface.py index 0f5b0842c..188d5b9e2 100644 --- a/python/vyos/configinterface.py +++ b/python/vyos/configinterface.py @@ -123,11 +123,9 @@ def add_interface_address(intf, addr): os.system('/opt/vyatta/sbin/vyatta-dhcpv6-client.pl --start -ifname "{}"'.format(intf)) elif vyos.validate.is_ipv4(addr): if not vyos.validate.is_intf_addr_assigned(intf, addr): - print("Assigning {} to {}".format(addr, intf)) os.system('sudo ip -4 addr add "{}" broadcast + dev "{}"'.format(addr, intf)) elif vyos.validate.is_ipv6(addr): if not vyos.validate.is_intf_addr_assigned(intf, addr): - print("Assigning {} to {}".format(addr, intf)) os.system('sudo ip -6 addr add "{}" dev "{}"'.format(addr, intf)) else: raise ConfigError('{} is not a valid interface address'.format(addr)) @@ -151,3 +149,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 |