diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-25 09:57:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 09:57:21 +0100 |
commit | 6e7739e0b69e1d3371ebe36218604cbb1aca18b1 (patch) | |
tree | c745b79a378c75e928931073bfddbf8cc76ca730 /python/vyos/interfaces.py | |
parent | 7c4d21639d9594ba4a0d96a5d6d90f25189c2817 (diff) | |
parent | bbea850ea5f8ff0402cd276ab63963ece7e0c763 (diff) | |
download | vyos-1x-6e7739e0b69e1d3371ebe36218604cbb1aca18b1.tar.gz vyos-1x-6e7739e0b69e1d3371ebe36218604cbb1aca18b1.zip |
Merge pull request #265 from thomas-mangin/2057-dhcp-vlan
ifconfig: T2057: break down DHCP, add register, STP and VLAN as adapters
Diffstat (limited to 'python/vyos/interfaces.py')
-rw-r--r-- | python/vyos/interfaces.py | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/python/vyos/interfaces.py b/python/vyos/interfaces.py index 37c093aca..4697c0acc 100644 --- a/python/vyos/interfaces.py +++ b/python/vyos/interfaces.py @@ -16,44 +16,10 @@ import re import json +from vyos.ifconfig import Interface import subprocess import netifaces -intf_type_data_file = '/usr/share/vyos/interface-types.json' - -def list_interfaces(): - interfaces = netifaces.interfaces() - - # Remove "fake" interfaces associated with drivers - for i in ["dummy0", "ip6tnl0", "tunl0", "ip_vti0", "ip6_vti0"]: - try: - interfaces.remove(i) - except ValueError: - pass - - return interfaces - -def list_interfaces_of_type(typ): - with open(intf_type_data_file, 'r') as f: - types_data = json.load(f) - - all_intfs = list_interfaces() - if not (typ in types_data.keys()): - raise ValueError("Unknown interface type: {0}".format(typ)) - else: - r = re.compile('^{0}\d+'.format(types_data[typ])) - return list(filter(lambda i: re.match(r, i), all_intfs)) - -def get_type_of_interface(intf): - with open(intf_type_data_file, 'r') as f: - types_data = json.load(f) - - for key,val in types_data.items(): - r = re.compile('^{0}\d+'.format(val)) - if re.match(r, intf): - return key - - raise ValueError("No type found for interface name: {0}".format(intf)) def wireguard_dump(): """Dump wireguard data in a python friendly way.""" |