diff options
author | Daniil Baturin <daniil@baturin.org> | 2024-07-29 19:16:43 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2024-07-29 19:16:43 +0100 |
commit | 30111fa493c72e7182854f295bc88d9eecccf419 (patch) | |
tree | 6fbcb396df88744e539eae75e56bb0835428fa65 /src/migration-scripts/openvpn | |
parent | 7724a5f58b515fbc094b4f211d455c1bd5071a74 (diff) | |
download | vyos-1x-30111fa493c72e7182854f295bc88d9eecccf419.tar.gz vyos-1x-30111fa493c72e7182854f295bc88d9eecccf419.zip |
vyos.configtree: T6620: allow list_nodes() to work on non-existent paths
and return an empty list in that case
(handy for migration scripts and the like)
Diffstat (limited to 'src/migration-scripts/openvpn')
-rw-r--r-- | src/migration-scripts/openvpn/1-to-2 | 8 | ||||
-rw-r--r-- | src/migration-scripts/openvpn/2-to-3 | 8 | ||||
-rw-r--r-- | src/migration-scripts/openvpn/3-to-4 | 6 |
3 files changed, 5 insertions, 17 deletions
diff --git a/src/migration-scripts/openvpn/1-to-2 b/src/migration-scripts/openvpn/1-to-2 index b7b7d4c77..2baa7302c 100644 --- a/src/migration-scripts/openvpn/1-to-2 +++ b/src/migration-scripts/openvpn/1-to-2 @@ -20,12 +20,8 @@ from vyos.configtree import ConfigTree def migrate(config: ConfigTree) -> None: - if not config.exists(['interfaces', 'openvpn']): - # Nothing to do - return - - ovpn_intfs = config.list_nodes(['interfaces', 'openvpn']) - for i in ovpn_intfs: + ovpn_intfs = config.list_nodes(['interfaces', 'openvpn'], path_must_exist=False) + for i in ovpn_intfs: # Remove 'encryption cipher' and add this value to 'encryption ncp-ciphers' # for server and client mode. # Site-to-site mode still can use --cipher option diff --git a/src/migration-scripts/openvpn/2-to-3 b/src/migration-scripts/openvpn/2-to-3 index 0b9073ae6..4e6b3c8b7 100644 --- a/src/migration-scripts/openvpn/2-to-3 +++ b/src/migration-scripts/openvpn/2-to-3 @@ -20,12 +20,8 @@ from vyos.configtree import ConfigTree def migrate(config: ConfigTree) -> None: - if not config.exists(['interfaces', 'openvpn']): - # Nothing to do - return - - ovpn_intfs = config.list_nodes(['interfaces', 'openvpn']) - for i in ovpn_intfs: + ovpn_intfs = config.list_nodes(['interfaces', 'openvpn'], path_must_exist=False) + for i in ovpn_intfs: mode = config.return_value(['interfaces', 'openvpn', i, 'mode']) if mode != 'server': # If it's a client or a site-to-site OpenVPN interface, diff --git a/src/migration-scripts/openvpn/3-to-4 b/src/migration-scripts/openvpn/3-to-4 index d3c76c7d3..0529491c1 100644 --- a/src/migration-scripts/openvpn/3-to-4 +++ b/src/migration-scripts/openvpn/3-to-4 @@ -18,11 +18,7 @@ from vyos.configtree import ConfigTree def migrate(config: ConfigTree) -> None: - if not config.exists(['interfaces', 'openvpn']): - # Nothing to do - return - - ovpn_intfs = config.list_nodes(['interfaces', 'openvpn']) + ovpn_intfs = config.list_nodes(['interfaces', 'openvpn'], path_must_exist=False) for i in ovpn_intfs: #Rename 'encryption ncp-ciphers' with 'encryption data-ciphers' ncp_cipher_path = ['interfaces', 'openvpn', i, 'encryption', 'ncp-ciphers'] |