diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2022-01-11 01:10:59 +0100 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2022-01-11 14:49:12 +0100 |
commit | 6cf5767524b8519f86981943ab71ff288bf77d67 (patch) | |
tree | b0fb06a0d51ad6c3ed39bfc631642c62b61d52cf /src/migration-scripts/policy | |
parent | e389729f4de84ce3f32e1a0cdb471c919d7d7807 (diff) | |
download | vyos-1x-6cf5767524b8519f86981943ab71ff288bf77d67.tar.gz vyos-1x-6cf5767524b8519f86981943ab71ff288bf77d67.zip |
policy: T2199: Refactor policy route script for better error handling
* Migrates all policy route references from `ipv6-route` to `route6`
* Update test config `dialup-router-medium-vpn` to test migration of `ipv6-route` to `route6`
Diffstat (limited to 'src/migration-scripts/policy')
-rwxr-xr-x | src/migration-scripts/policy/1-to-2 | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/migration-scripts/policy/1-to-2 b/src/migration-scripts/policy/1-to-2 index 3e46227de..7ffceef22 100755 --- a/src/migration-scripts/policy/1-to-2 +++ b/src/migration-scripts/policy/1-to-2 @@ -41,6 +41,24 @@ if not config.exists(base): config.rename(base, 'route6') config.set_tag(['policy', 'route6']) +if config.exists(['interfaces']): + def if_policy_rename(config, path): + if config.exists(path + ['policy', 'ipv6-route']): + config.rename(path + ['policy', 'ipv6-route'], 'route6') + + for if_type in config.list_nodes(['interfaces']): + for ifname in config.list_nodes(['interfaces', if_type]): + if_path = ['interfaces', if_type, ifname] + if_policy_rename(config, if_path) + + for vif_type in ['vif', 'vif-s']: + if config.exists(if_path + [vif_type]): + for vifname in config.list_nodes(if_path + [vif_type]): + if_policy_rename(config, if_path + [vif_type, vifname]) + + if config.exists(if_path + [vif_type, vifname, 'vif-c']): + for vifcname in config.list_nodes(if_path + [vif_type, vifname, 'vif-c']): + if_policy_rename(config, if_path + [vif_type, vifname, 'vif-c', vifcname]) try: with open(file_name, 'w') as f: f.write(config.to_string()) |