summaryrefslogtreecommitdiff
path: root/python/vyos/config_mgmt.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-20 08:13:04 +0100
committerGitHub <noreply@github.com>2023-11-20 08:13:04 +0100
commit293f6b2ea882ebbf5b54e9ff19b1854e627a06c3 (patch)
treeebefd4ed971efeae29670071e17bdb2bf52557d0 /python/vyos/config_mgmt.py
parentcd19b9d6b0c21a5d07a9f5a98e5e90d09d8d4cc9 (diff)
parentd87dfa557c962b9ac1bb7483a3b419095ae5fccf (diff)
downloadvyos-1x-293f6b2ea882ebbf5b54e9ff19b1854e627a06c3.tar.gz
vyos-1x-293f6b2ea882ebbf5b54e9ff19b1854e627a06c3.zip
Merge pull request #2505 from vyos/mergify/bp/sagitta/pr-2241
T2405: add Git support to commit-archive (backport #2241)
Diffstat (limited to 'python/vyos/config_mgmt.py')
-rw-r--r--python/vyos/config_mgmt.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py
index 654a8d698..df7240c88 100644
--- a/python/vyos/config_mgmt.py
+++ b/python/vyos/config_mgmt.py
@@ -22,10 +22,11 @@ import logging
from typing import Optional, Tuple, Union
from filecmp import cmp
from datetime import datetime
-from textwrap import dedent
+from textwrap import dedent, indent
from pathlib import Path
from tabulate import tabulate
from shutil import copy, chown
+from urllib.parse import urlsplit, urlunsplit
from vyos.config import Config
from vyos.configtree import ConfigTree, ConfigTreeError, show_diff
@@ -377,9 +378,22 @@ Proceed ?'''
remote_file = f'config.boot-{hostname}.{timestamp}'
source_address = self.source_address
+ if self.effective_locations:
+ print("Archiving config...")
for location in self.effective_locations:
- upload(archive_config_file, f'{location}/{remote_file}',
- source_host=source_address)
+ url = urlsplit(location)
+ _, _, netloc = url.netloc.rpartition("@")
+ redacted_location = urlunsplit(url._replace(netloc=netloc))
+ print(f" {redacted_location}", end=" ", flush=True)
+ try:
+ upload(archive_config_file, f'{location}/{remote_file}',
+ source_host=source_address, raise_error=True)
+ print("OK")
+ except Exception as e:
+ print("FAILED!")
+ print()
+ print(indent(str(e), " > "))
+ print()
# op-mode functions
#