diff options
author | Daniil Baturin <daniil@vyos.io> | 2021-02-22 17:03:05 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2021-02-22 17:03:05 +0200 |
commit | 28cd2e3edb3e2108c43ad20c0084d496a7ffef25 (patch) | |
tree | 3ab548dcce3a63e4cfe58a7b57440d82283533ff /src/migration-scripts | |
parent | 51dc9eb8c0692fe68223538e634bdbd25363a862 (diff) | |
download | vyos-1x-28cd2e3edb3e2108c43ad20c0084d496a7ffef25.tar.gz vyos-1x-28cd2e3edb3e2108c43ad20c0084d496a7ffef25.zip |
T3346: handle the case of empty nodes when migrating NAT to syntax version 5
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-x | src/migration-scripts/nat/4-to-5 | 6 |
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] |