summaryrefslogtreecommitdiff
path: root/src/migration-scripts/interfaces/20-to-21
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-06-13 13:17:02 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-13 13:17:02 +0200
commit7065d0c4fe08b094aaf0970dc12a2045f5b80c86 (patch)
tree73aa332bb293cdb2cef740cf56058ca2746ed70d /src/migration-scripts/interfaces/20-to-21
parent5c47a1bdb5f5bedb86a2ecb40010bca97369584f (diff)
downloadvyos-1x-7065d0c4fe08b094aaf0970dc12a2045f5b80c86.tar.gz
vyos-1x-7065d0c4fe08b094aaf0970dc12a2045f5b80c86.zip
wwan: T3620: reorder mirgation scripts for 1.3 backport
As the new WWAN interface style is backported to VyOS 1.3 we also need to shift the order of the interface migration scripts. so the same order from VyOS 1.4 also applies to VyOS 1.3. In short, 21-to-22 is renamed to 18-to-19 and all other migrators are shifted up one version.
Diffstat (limited to 'src/migration-scripts/interfaces/20-to-21')
-rwxr-xr-xsrc/migration-scripts/interfaces/20-to-2159
1 files changed, 30 insertions, 29 deletions
diff --git a/src/migration-scripts/interfaces/20-to-21 b/src/migration-scripts/interfaces/20-to-21
index d1ec2ad3e..e96663e54 100755
--- a/src/migration-scripts/interfaces/20-to-21
+++ b/src/migration-scripts/interfaces/20-to-21
@@ -14,47 +14,48 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# A VTI interface also requires an IPSec configuration - VyOS 1.2 supported
-# having a VTI interface in the CLI but no IPSec configuration - drop VTI
-# configuration if this is the case for VyOS 1.4
-
-import sys
+from sys import argv
+from sys import exit
from vyos.configtree import ConfigTree
if __name__ == '__main__':
- if (len(sys.argv) < 1):
+ if (len(argv) < 1):
print("Must specify file name!")
- sys.exit(1)
-
- file_name = sys.argv[1]
+ exit(1)
+ file_name = argv[1]
with open(file_name, 'r') as f:
config_file = f.read()
config = ConfigTree(config_file)
- base = ['interfaces', 'vti']
- if not config.exists(base):
- # Nothing to do
- sys.exit(0)
-
- ipsec_base = ['vpn', 'ipsec', 'site-to-site', 'peer']
- for interface in config.list_nodes(base):
- found = False
- if config.exists(ipsec_base):
- for peer in config.list_nodes(ipsec_base):
- if config.exists(ipsec_base + [peer, 'vti', 'bind']):
- tmp = config.return_value(ipsec_base + [peer, 'vti', 'bind'])
- if tmp == interface:
- # Interface was found and we no longer need to search
- # for it in our IPSec peers
- found = True
- break
- if not found:
- config.delete(base + [interface])
+
+ 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 <tunX> 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 <interface> local-ip" to source-address
+ # Migrate "interface tunnel|l2tpv3 <interface> 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:
f.write(config.to_string())
except OSError as e:
print("Failed to save the modified config: {}".format(e))
- sys.exit(1)
+ exit(1)