From 28cd2e3edb3e2108c43ad20c0084d496a7ffef25 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 22 Feb 2021 17:03:05 +0200 Subject: T3346: handle the case of empty nodes when migrating NAT to syntax version 5 --- src/migration-scripts/nat/4-to-5 | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/migration-scripts/nat/4-to-5 b/src/migration-scripts/nat/4-to-5 index dda191719..b791996e2 100755 --- a/src/migration-scripts/nat/4-to-5 +++ b/src/migration-scripts/nat/4-to-5 @@ -36,9 +36,15 @@ if not config.exists(['nat']): exit(0) else: for direction in ['source', 'destination']: + # If a node doesn't exist, we obviously have nothing to do. if not config.exists(['nat', direction]): continue + # However, we also need to handle the case when a 'source' or 'destination' sub-node does exist, + # but there are no rules under it. + if not config.list_nodes(['nat', direction]): + continue + for rule in config.list_nodes(['nat', direction, 'rule']): base = ['nat', direction, 'rule', rule] -- cgit v1.2.3