diff options
Diffstat (limited to 'src/migration-scripts/nat66/0-to-1')
-rwxr-xr-x | src/migration-scripts/nat66/0-to-1 | 35 |
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) |