diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-01-26 20:47:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-26 20:47:49 +0100 |
commit | c8e32f6adff3bf9f5721581c1a8cb8936677a7d5 (patch) | |
tree | 737c8b11a1980b05089b04770433489704a0e5a1 | |
parent | 5177313cfc127515a38419c6c98acb989c5e75e5 (diff) | |
parent | 3523da8e4c87c96ae6fede6a5bc0fd2e96dcabc9 (diff) | |
download | vyos-1x-c8e32f6adff3bf9f5721581c1a8cb8936677a7d5.tar.gz vyos-1x-c8e32f6adff3bf9f5721581c1a8cb8936677a7d5.zip |
Merge pull request #1192 from sarthurdev/T4212
pki: T4212: Catch `install_into_config` errors and output for manual command entry
-rw-r--r-- | python/vyos/util.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 954c6670d..571d43754 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -952,14 +952,23 @@ def install_into_config(conf, config_paths, override_prompt=True): return None count = 0 + failed = [] for path in config_paths: if override_prompt and conf.exists(path) and not conf.is_multi(path): if not ask_yes_no(f'Config node "{node}" already exists. Do you want to overwrite it?'): continue - cmd(f'/opt/vyatta/sbin/my_set {path}') - count += 1 + try: + cmd(f'/opt/vyatta/sbin/my_set {path}') + count += 1 + except: + failed.append(path) + + if failed: + print(f'Failed to install {len(failed)} value(s). Commands to manually install:') + for path in failed: + print(f'set {path}') if count > 0: print(f'{count} value(s) installed. Use "compare" to see the pending changes, and "commit" to apply.') |