summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-02-22 17:03:05 +0200
committerDaniil Baturin <daniil@vyos.io>2021-02-22 17:03:50 +0200
commitefc0ecb17de5c6661d092fd990dfdabe9e6b60ef (patch)
tree4744282d0ac22eb24df28f8b4dfbc2e649482d38
parent20e500b8a4f62fe1f2603ba5daebad3ee49db39a (diff)
downloadvyos-1x-efc0ecb17de5c6661d092fd990dfdabe9e6b60ef.tar.gz
vyos-1x-efc0ecb17de5c6661d092fd990dfdabe9e6b60ef.zip
T3346: handle the case of empty nodes when migrating NAT to syntax version 5
-rwxr-xr-xsrc/migration-scripts/nat/4-to-56
1 files changed, 6 insertions, 0 deletions
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]