From 53ce5e378ace1d94dedeba0d84c353fbb3b59433 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Mon, 5 May 2025 12:10:25 -0500 Subject: T7417: check existence of path before set_tag The migration script assumed the existence of path ['vrf', 'name', tag-val-name, 'protocols', 'static', 'route'] ignoring sole entries for [..., 'route6']. Check existence of each path before calling set_tag. --- src/migration-scripts/vrf/1-to-2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/migration-scripts/vrf') diff --git a/src/migration-scripts/vrf/1-to-2 b/src/migration-scripts/vrf/1-to-2 index 557a9ec58..89b0f708a 100644 --- a/src/migration-scripts/vrf/1-to-2 +++ b/src/migration-scripts/vrf/1-to-2 @@ -37,7 +37,10 @@ def migrate(config: ConfigTree) -> None: new_static_base = vrf_base + [vrf, 'protocols'] config.set(new_static_base) config.copy(static_base, new_static_base + ['static']) - config.set_tag(new_static_base + ['static', 'route']) + if config.exists(new_static_base + ['static', 'route']): + config.set_tag(new_static_base + ['static', 'route']) + if config.exists(new_static_base + ['static', 'route6']): + config.set_tag(new_static_base + ['static', 'route6']) # Now delete the old configuration config.delete(base) -- cgit v1.2.3 From 40c82fd472c4961e506acea86461833e9b244f98 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Mon, 5 May 2025 13:16:54 -0500 Subject: T7417: check existence of table setting before return_value Migration from 1.3.x may not contain table entries, later required. The migration script should not fail with error, leaving enforcement to config scripts. --- src/migration-scripts/vrf/2-to-3 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/migration-scripts/vrf') diff --git a/src/migration-scripts/vrf/2-to-3 b/src/migration-scripts/vrf/2-to-3 index acacffb41..5f396e7ed 100644 --- a/src/migration-scripts/vrf/2-to-3 +++ b/src/migration-scripts/vrf/2-to-3 @@ -76,7 +76,8 @@ def migrate(config: ConfigTree) -> None: # Get a list of all currently used VRFs and tables vrfs_current = {} for vrf in config.list_nodes(base): - vrfs_current[vrf] = int(config.return_value(base + [vrf, 'table'])) + if config.exists(base + [vrf, 'table']): + vrfs_current[vrf] = int(config.return_value(base + [vrf, 'table'])) # Check VRF names and table numbers name_regex = re.compile(r'^\d.*$') -- cgit v1.2.3