summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-01-25 17:30:28 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-01-25 20:23:06 -0600
commitb1d2bb907c537f99ee8011947cda45084076ecba (patch)
tree661f2d793048d272ef2cbab7edf056bbfd1e8e99 /python
parent55d83a1f138d1e31288d068c823a53a3ccecc72f (diff)
downloadvyos-1x-b1d2bb907c537f99ee8011947cda45084076ecba.tar.gz
vyos-1x-b1d2bb907c537f99ee8011947cda45084076ecba.zip
config-mgmt: T4957: upload to archive only for location effective_values
Diffstat (limited to 'python')
-rw-r--r--python/vyos/config_mgmt.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py
index 8ec73ac28..1be63b08f 100644
--- a/python/vyos/config_mgmt.py
+++ b/python/vyos/config_mgmt.py
@@ -82,6 +82,15 @@ class ConfigMgmt:
else:
self.hostname = 'vyos'
+ # upload only on existence of effective values, notably, on boot.
+ # one still needs session self.locations (above) for setting
+ # post-commit hook in conf_mode script
+ path = ['system', 'config-management', 'commit-archive', 'location']
+ if config.exists_effective(path):
+ self.effective_locations = config.return_effective_values(path)
+ else:
+ self.effective_locations = []
+
# a call to compare without args is edit_level aware
edit_level = os.getenv('VYATTA_EDIT_LEVEL', '')
edit_path = [l for l in edit_level.split('/') if l]
@@ -346,7 +355,7 @@ Proceed ?'''
remote_file = f'config.boot-{hostname}.{timestamp}'
source_address = self.source_address
- for location in self.locations:
+ for location in self.effective_locations:
upload(archive_config_file, f'{location}/{remote_file}',
source_host=source_address)
@@ -618,7 +627,10 @@ def run():
for s in list(commit_hooks):
if sys.argv[0].replace('-', '_').endswith(s):
func = getattr(config_mgmt, s)
- func()
+ try:
+ func()
+ except Exception as e:
+ print(f'{s}: {e}')
sys.exit(0)
parser = ArgumentParser()