diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-07-01 20:50:57 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-07-01 20:50:57 +0200 |
commit | 469e57398f3a9700fee210a94e57601f51466f43 (patch) | |
tree | 4b0b4e7e8ea68938511a62e990a7d1b24de1d7ee /python/vyos/util.py | |
parent | d565d4baffb930462f1a913d6f8a80111958a6f8 (diff) | |
parent | 30e4f083c98f93058c59f89e140819f7a3151f43 (diff) | |
download | vyos-1x-469e57398f3a9700fee210a94e57601f51466f43.tar.gz vyos-1x-469e57398f3a9700fee210a94e57601f51466f43.zip |
Merge branch 'pki_ipsec' of https://github.com/sarthurdev/vyos-1x into pki-cli
* 'pki_ipsec' of https://github.com/sarthurdev/vyos-1x:
pki: ipsec: T3642: Update migration script to account for file permission issues
pki: ipsec: T3642: Migrate IPSec to use PKI configuration
pki: T3642: New PKI config and management
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 446285a1b..65c9c2f45 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -572,6 +572,25 @@ def wait_for_commit_lock(): while commit_in_progress(): sleep(1) +def ask_input(question, default='', numeric_only=False, valid_responses=[]): + question_out = question + if default: + question_out += f' (Default: {default})' + response = '' + while True: + response = input(question_out + ' ').strip() + if not response and default: + return default + if numeric_only: + if not response.isnumeric(): + print("Invalid value, try again.") + continue + response = int(response) + if valid_responses and response not in valid_responses: + print("Invalid value, try again.") + continue + break + return response def ask_yes_no(question, default=False) -> bool: """Ask a yes/no question via input() and return their answer.""" |