From 5574bd672825a87b1983cc135ae2e0bdabbe751b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 28 Feb 2021 10:14:20 +0100 Subject: l2tpv3: T3366: migrate local-ip and remote-ip CLI options Rename CLI options local-ip to source-address and remote-ip to remote to get a consistent CLI experience for the user. --- src/migration-scripts/interfaces/19-to-20 | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/migration-scripts') diff --git a/src/migration-scripts/interfaces/19-to-20 b/src/migration-scripts/interfaces/19-to-20 index ed2780b92..e96663e54 100755 --- a/src/migration-scripts/interfaces/19-to-20 +++ b/src/migration-scripts/interfaces/19-to-20 @@ -28,30 +28,30 @@ if __name__ == '__main__': config_file = f.read() config = ConfigTree(config_file) - base = ['interfaces', 'tunnel'] - - if not config.exists(base): - # Nothing to do - exit(0) - - # - # Migrate "interface tunnel encapsulation gre-bridge" to gretap - # Migrate "interface tunnel local-ip" to source-address - # Migrate "interface tunnel remote-ip" to remote - for interface in config.list_nodes(base): - encap_path = base + [interface, 'encapsulation'] - if config.exists(encap_path): - tmp = config.return_value(encap_path) - if tmp == 'gre-bridge': - config.set(encap_path, value='gretap') - - local_ip_path = base + [interface, 'local-ip'] - if config.exists(local_ip_path): - config.rename(local_ip_path, 'source-address') - - remote_ip_path = base + [interface, 'remote-ip'] - if config.exists(remote_ip_path): - config.rename(remote_ip_path, 'remote') + + for type in ['tunnel', 'l2tpv3']: + base = ['interfaces', type] + if not config.exists(base): + # Nothing to do + continue + + for interface in config.list_nodes(base): + # Migrate "interface tunnel encapsulation gre-bridge" to gretap + encap_path = base + [interface, 'encapsulation'] + if type == 'tunnel' and config.exists(encap_path): + tmp = config.return_value(encap_path) + if tmp == 'gre-bridge': + config.set(encap_path, value='gretap') + + # Migrate "interface tunnel|l2tpv3 local-ip" to source-address + # Migrate "interface tunnel|l2tpv3 remote-ip" to remote + local_ip_path = base + [interface, 'local-ip'] + if config.exists(local_ip_path): + config.rename(local_ip_path, 'source-address') + + remote_ip_path = base + [interface, 'remote-ip'] + if config.exists(remote_ip_path): + config.rename(remote_ip_path, 'remote') try: with open(file_name, 'w') as f: -- cgit v1.2.3