summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJACK <jack9603301@163.com>2021-01-23 03:58:48 +0800
committerjack9603301 <jack9603301@163.com>2021-01-23 21:45:31 +0800
commit9d2ce9c1d0078a16c698c7c5ce503044c780b04d (patch)
treea0f186ab1ed8bd2b1deb2f6e4fedcb477ae9e80d /src
parentd5a6817f5dc8c6b6bc015705330efbd02750d801 (diff)
downloadvyos-1x-9d2ce9c1d0078a16c698c7c5ce503044c780b04d.tar.gz
vyos-1x-9d2ce9c1d0078a16c698c7c5ce503044c780b04d.zip
nptv6: T2518: Remove redundant paths for migration scripts
Diffstat (limited to 'src')
-rwxr-xr-xsrc/migration-scripts/nat66/0-to-135
1 files changed, 16 insertions, 19 deletions
diff --git a/src/migration-scripts/nat66/0-to-1 b/src/migration-scripts/nat66/0-to-1
index 2bc22061d..67024cf77 100755
--- a/src/migration-scripts/nat66/0-to-1
+++ b/src/migration-scripts/nat66/0-to-1
@@ -52,25 +52,22 @@ def merge_npt(config,base,rule):
config.set(merge_base + ['translation','prefix'],value=tmp)
-if not config.exists(['nat']):
+if not config.exists(['nat', 'nptv6']):
# Nothing to do
exit(0)
-else:
- if not config.exists(['nat', 'nptv6']):
- exit(0)
-
- for rule in config.list_nodes(['nat', 'nptv6', 'rule']):
- base = ['nat', 'nptv6', 'rule', rule]
- # Merge 'nat nptv6' to 'nat66 source'
- merge_npt(config,base,rule)
-
- # Delete the original NPT configuration
- config.delete(['nat','nptv6']);
-
- 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))
- exit(1)
+
+for rule in config.list_nodes(['nat', 'nptv6', 'rule']):
+ base = ['nat', 'nptv6', 'rule', rule]
+ # Merge 'nat nptv6' to 'nat66 source'
+ merge_npt(config,base,rule)
+
+# Delete the original NPT configuration
+config.delete(['nat','nptv6']);
+
+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))
+ exit(1)