diff options
author | Daniil Baturin <daniil@vyos.io> | 2023-03-07 19:51:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 19:51:18 +0000 |
commit | 06e810ffc398366f7d4cc00241e0692e6fe81620 (patch) | |
tree | a1e2d444b83eadbb8f0e7f43b6493a03c6f90c8a /src/op_mode/openvpn.py | |
parent | 9f0857c2e7821ea22d5132d6352ee8cbcb64b738 (diff) | |
parent | 1e72e1c68a708518526b8e090f5d6482671cbd57 (diff) | |
download | vyos-1x-06e810ffc398366f7d4cc00241e0692e6fe81620.tar.gz vyos-1x-06e810ffc398366f7d4cc00241e0692e6fe81620.zip |
Merge pull request #1868 from jestabro/literal
op-mode: T5051: use Literal types to provide op-mode CLI choices and API enums
Diffstat (limited to 'src/op_mode/openvpn.py')
-rwxr-xr-x | src/op_mode/openvpn.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/op_mode/openvpn.py b/src/op_mode/openvpn.py index 79130c7c0..8f88ab422 100755 --- a/src/op_mode/openvpn.py +++ b/src/op_mode/openvpn.py @@ -18,6 +18,7 @@ import os import sys +import typing from tabulate import tabulate import vyos.opmode @@ -26,6 +27,8 @@ from vyos.util import commit_in_progress from vyos.util import call from vyos.config import Config +ArgMode = typing.Literal['client', 'server', 'site_to_site'] + def _get_tunnel_address(peer_host, peer_port, status_file): peer = peer_host + ':' + peer_port lst = [] @@ -155,7 +158,7 @@ def _get_raw_data(mode: str) -> dict: d['local_port'] = conf_dict[intf].get('local-port', '') if conf.exists(f'interfaces openvpn {intf} server client'): d['configured_clients'] = conf.list_nodes(f'interfaces openvpn {intf} server client') - if mode in ['client', 'site-to-site']: + if mode in ['client', 'site_to_site']: for client in d['clients']: if 'shared-secret-key-file' in list(conf_dict[intf]): client['name'] = 'None (PSK)' @@ -198,7 +201,7 @@ def _format_openvpn(data: dict) -> str: return out -def show(raw: bool, mode: str) -> str: +def show(raw: bool, mode: ArgMode) -> str: openvpn_data = _get_raw_data(mode) if raw: |