From 9d2ce9c1d0078a16c698c7c5ce503044c780b04d Mon Sep 17 00:00:00 2001 From: JACK Date: Sat, 23 Jan 2021 03:58:48 +0800 Subject: nptv6: T2518: Remove redundant paths for migration scripts --- src/migration-scripts/nat66/0-to-1 | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/migration-scripts/nat66') 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) -- cgit v1.2.3