diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-24 18:36:46 +0000 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-03-24 18:36:46 +0000 |
commit | bbea850ea5f8ff0402cd276ab63963ece7e0c763 (patch) | |
tree | 4f5a4a5fa2a7c94e3051e905cadcefc389046883 /src/migration-scripts/dns-forwarding | |
parent | 8ac524b6d12618d696fa883ff78ded8c35c26d05 (diff) | |
download | vyos-1x-bbea850ea5f8ff0402cd276ab63963ece7e0c763.tar.gz vyos-1x-bbea850ea5f8ff0402cd276ab63963ece7e0c763.zip |
ifconfig: T2057: remove need for interface-types.json
Diffstat (limited to 'src/migration-scripts/dns-forwarding')
-rwxr-xr-x | src/migration-scripts/dns-forwarding/1-to-2 | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/migration-scripts/dns-forwarding/1-to-2 b/src/migration-scripts/dns-forwarding/1-to-2 index 31ba5573f..9a50b6aa3 100755 --- a/src/migration-scripts/dns-forwarding/1-to-2 +++ b/src/migration-scripts/dns-forwarding/1-to-2 @@ -23,8 +23,8 @@ import sys from ipaddress import ip_interface +from vyos.ifconfig import Interface from vyos.configtree import ConfigTree -from vyos.interfaces import get_type_of_interface if (len(sys.argv) < 1): print("Must specify file name!") @@ -41,7 +41,10 @@ base = ['service', 'dns', 'forwarding'] if not config.exists(base): # Nothing to do sys.exit(0) + else: + # XXX: we can remove the else and un-indent this whole block + if config.exists(base + ['listen-on']): listen_intf = config.return_values(base + ['listen-on']) # Delete node with abandoned command @@ -60,7 +63,10 @@ else: # this is a QinQ VLAN interface intf = intf.split('.')[0] + ' vif-s ' + intf.split('.')[1] + ' vif-c ' + intf.split('.')[2] - path = ['interfaces', get_type_of_interface(intf), intf, 'address'] + section = Interface.section(intf) + if not section: + raise ValueError(f'Invalid interface name {intf}') + path = ['interfaces', section, intf, 'address'] # retrieve corresponding interface addresses in CIDR format # those need to be converted in pure IP addresses without network information |