From 07273632fcf59d04be988f2c43fe53e7bec8d46a Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 23 Feb 2020 12:22:34 +0100 Subject: pppoe: T1318: rename link to source-interface --- src/conf_mode/interfaces-pppoe.py | 16 +++--- src/migration-scripts/interfaces/4-to-5 | 91 +++++---------------------------- 2 files changed, 22 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index 6ab3fbd95..49902b989 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -64,7 +64,7 @@ noauth noproxyarp plugin rp-pppoe.so -{{ link }} +{{ source_interface }} persist ifname {{ intf }} ipparam {{ intf }} @@ -100,14 +100,14 @@ default_config_data = { 'idle_timeout': '', 'ipv6_autoconf': False, 'ipv6_enable': False, - 'link': '', 'local_address': '', 'mtu': '1492', 'name_server': 'auto', 'password': '', 'remote_address': '', 'service_name': '', - 'user_id': '' + 'user_id': '', + 'source_interface': '' } def subprocess_cmd(command): @@ -165,13 +165,13 @@ def get_config(): if conf.exists(['ipv6', 'enable']): pppoe['ipv6_enable'] = True - # IPv4 address of local end of the PPPoE link + # IPv4 address of local end of PPPoE link if conf.exists(['local-address']): pppoe['local_address'] = conf.return_value(['local-address']) # Physical Interface used for this PPPoE session - if conf.exists(['link']): - pppoe['link'] = conf.return_value('link') + if conf.exists(['source-interface']): + pppoe['source_interface'] = conf.return_value('source-interface') # Maximum Transmission Unit (MTU) if conf.exists(['mtu']): @@ -204,8 +204,8 @@ def verify(pppoe): # bail out early return None - if not pppoe['link']: - raise ConfigError('Physical link interface for PPPoE missing') + if not pppoe['source_interface']: + raise ConfigError('PPPoE source interface is missing') return None diff --git a/src/migration-scripts/interfaces/4-to-5 b/src/migration-scripts/interfaces/4-to-5 index db2be4a66..0683861f2 100755 --- a/src/migration-scripts/interfaces/4-to-5 +++ b/src/migration-scripts/interfaces/4-to-5 @@ -9,91 +9,28 @@ from vyos.configtree import ConfigTree def migrate_dialer(config, tree, intf): for pppoe in config.list_nodes(tree): # assemble string, 0 -> pppoe0 - new_base = ['interfaces', 'pppoe', 'pppoe' + pppoe] + new_base = ['interfaces', 'pppoe'] + pppoe_base = new_base + ['pppoe' + pppoe] config.set(new_base) # format as tag node to avoid loading problems - config.set_tag(['interfaces', 'pppoe']) - - # - # Firewall migrieren - # - firewall = tree + [pppoe, 'firewall'] - if config.exists(firewall): - config.copy(firewall, new_base + ['firewall']) - - policy = tree + [pppoe, 'policy'] - if config.exists(policy): - config.copy(policy, new_base + ['policy']) - - # - # QoS migrieren - # - redirect = tree + [pppoe, 'redirect'] - if config.exists(redirect): - config.copy(redirect, new_base + ['redirect']) - - traffic_policy = tree + [pppoe, 'traffic-policy'] - if config.exists(traffic_policy): - config.copy(traffic_policy, new_base + ['traffic-policy']) - - # - # Quagga migrieren - # - ip = tree + [pppoe, 'ip'] - if config.exists(ip): - config.copy(ip, new_base + ['ip']) - - ipv6 = tree + [pppoe, 'ipv6'] - if config.exists(ipv6): - config.copy(ipv6, new_base + ['ipv6']) - - # - # Interface migration - # - config.set(new_base + ['link'], value=intf) - - default_route = tree + [pppoe, 'default-route'] - if config.exists(default_route): - tmp = config.return_value(default_route) - config.set(new_base + ['default-route'], value=tmp) - - disable = tree + [pppoe, 'disable'] - if config.exists(disable): - tmp = config.return_value(disable) - config.set(new_base + ['disable'], value=tmp) - - mtu = tree + [pppoe, 'mtu'] - if config.exists(mtu): - tmp = config.return_value(mtu) - config.set(new_base + ['mtu'], value=tmp) - - nameserver = tree + [pppoe, 'name-server'] - if config.exists(nameserver): - tmp = config.return_value(nameserver) - config.set(new_base + ['name-server'], value=tmp) - - password = tree + [pppoe, 'password'] - if config.exists(password): - tmp = config.return_value(password) - config.set(new_base + ['password'], value=tmp) - - userid = tree + [pppoe, 'user-id'] - if config.exists(userid): - tmp = config.return_value(userid) - config.set(new_base + ['user-id'], value=tmp) + config.set_tag(new_base) + + # Copy the entire old node to the new one before migrating individual + # parts + config.copy(tree + [pppoe], pppoe_base) + # remove enable-ipv6 node and rather place it under ipv6 node - ipv6_enable = tree + [pppoe, 'enable-ipv6'] - if config.exists(ipv6_enable): - config.set(new_base + ['ipv6', 'enable']) + if config.exists(pppoe_base + ['enable-ipv6']): + config.set(pppoe_base + ['ipv6', 'enable']) + config.delete(pppoe_base + ['enable-ipv6']) - ipv6_slaac = tree + [pppoe, 'ipv6', 'address', 'autoconf'] - if config.exists(ipv6_slaac): - config.set(new_base + ['ipv6', 'address', 'autoconf']) + # Source interface migration + config.set(pppoe_base + ['source-interface'], value=intf) -if __name__ == '__main__': +if __name__ == '__main__': if (len(sys.argv) < 1): print("Must specify file name!") exit(1) -- cgit v1.2.3