From 8c43dea52c1f3507b8176d7dd3e146f0cb8d476d Mon Sep 17 00:00:00 2001 From: Nicolas Fort Date: Tue, 2 Jul 2024 08:54:11 -0300 Subject: T6536: nat: add migration script that replaces wildcard charater supported in 1.3 <+> with character supported in latest version <*> (cherry picked from commit 148af29b68416a5b8d0e025a16aef252fdf31e67) # Conflicts: # src/migration-scripts/nat/6-to-7 --- src/migration-scripts/nat/6-to-7 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/migration-scripts/nat/6-to-7 b/src/migration-scripts/nat/6-to-7 index a2e735394..54968f52f 100755 --- a/src/migration-scripts/nat/6-to-7 +++ b/src/migration-scripts/nat/6-to-7 @@ -35,6 +35,7 @@ file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() +<<<<<<< HEAD config = ConfigTree(config_file) if not config.exists(['nat']): @@ -69,3 +70,18 @@ try: except OSError as e: print("Failed to save the modified config: {}".format(e)) exit(1) +======= + for rule in config.list_nodes(['nat', direction, 'rule']): + base = ['nat', direction, 'rule', rule] + for iface in ['inbound-interface','outbound-interface']: + if config.exists(base + [iface]): + if config.exists(base + [iface, 'interface-name']): + tmp = config.return_value(base + [iface, 'interface-name']) + if tmp != 'any': + config.delete(base + [iface, 'interface-name']) + if '+' in tmp: + tmp = tmp.replace('+', '*') + config.set(base + [iface, 'name'], value=tmp) + else: + config.delete(base + [iface]) +>>>>>>> 148af29b6 (T6536: nat: add migration script that replaces wildcard charater supported in 1.3 <+> with character supported in latest version <*>) -- cgit v1.2.3 From 20d4ffd527ccea5fb78f2f9e56c887bbc041b1e0 Mon Sep 17 00:00:00 2001 From: Nicolas Fort Date: Wed, 3 Jul 2024 09:53:56 -0300 Subject: T6536: change wildcard character from + to * - extend fix to interfaces defined in zone policy. (cherry picked from commit 66ec278393dbabe71f320c543816f27797d51140) --- src/migration-scripts/firewall/7-to-8 | 6 ++++++ src/migration-scripts/nat/6-to-7 | 18 ++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/migration-scripts/firewall/7-to-8 b/src/migration-scripts/firewall/7-to-8 index bbaba113a..17af0f355 100755 --- a/src/migration-scripts/firewall/7-to-8 +++ b/src/migration-scripts/firewall/7-to-8 @@ -84,6 +84,12 @@ if config.exists(zone_base + ['zone']): config.set_tag(['firewall', 'zone']) for zone in config.list_nodes(zone_base + ['zone']): + if 'interface' in config.list_nodes(zone_base + ['zone', zone]): + for iface in config.return_values(zone_base + ['zone', zone, 'interface']): + if '+' in iface: + config.delete_value(zone_base + ['zone', zone, 'interface'], value=iface) + iface = iface.replace('+', '*') + config.set(zone_base + ['zone', zone, 'interface'], value=iface, replace=False) config.copy(zone_base + ['zone', zone], ['firewall', 'zone', zone]) config.delete(zone_base) diff --git a/src/migration-scripts/nat/6-to-7 b/src/migration-scripts/nat/6-to-7 index 54968f52f..25640dec2 100755 --- a/src/migration-scripts/nat/6-to-7 +++ b/src/migration-scripts/nat/6-to-7 @@ -35,7 +35,6 @@ file_name = argv[1] with open(file_name, 'r') as f: config_file = f.read() -<<<<<<< HEAD config = ConfigTree(config_file) if not config.exists(['nat']): @@ -60,6 +59,8 @@ for direction in ['source', 'destination']: tmp = config.return_value(base + [iface, 'interface-name']) if tmp != 'any': config.delete(base + [iface, 'interface-name']) + if '+' in tmp: + tmp = tmp.replace('+', '*') config.set(base + [iface, 'name'], value=tmp) else: config.delete(base + [iface]) @@ -70,18 +71,3 @@ try: except OSError as e: print("Failed to save the modified config: {}".format(e)) exit(1) -======= - for rule in config.list_nodes(['nat', direction, 'rule']): - base = ['nat', direction, 'rule', rule] - for iface in ['inbound-interface','outbound-interface']: - if config.exists(base + [iface]): - if config.exists(base + [iface, 'interface-name']): - tmp = config.return_value(base + [iface, 'interface-name']) - if tmp != 'any': - config.delete(base + [iface, 'interface-name']) - if '+' in tmp: - tmp = tmp.replace('+', '*') - config.set(base + [iface, 'name'], value=tmp) - else: - config.delete(base + [iface]) ->>>>>>> 148af29b6 (T6536: nat: add migration script that replaces wildcard charater supported in 1.3 <+> with character supported in latest version <*>) -- cgit v1.2.3