diff options
author | Yun Zheng Hu <hu@fox-it.com> | 2023-11-18 21:34:15 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2023-11-19 09:17:55 +0100 |
commit | 949a4babb3daf1c585125fa71942fc7fa7832cdf (patch) | |
tree | a452015e8562a44a63db087cdc79e35bdca93f24 /python/vyos/config_mgmt.py | |
parent | cd19b9d6b0c21a5d07a9f5a98e5e90d09d8d4cc9 (diff) | |
download | vyos-1x-949a4babb3daf1c585125fa71942fc7fa7832cdf.tar.gz vyos-1x-949a4babb3daf1c585125fa71942fc7fa7832cdf.zip |
T2405: add Git support to commit-archive
(cherry picked from commit a89243cfbfc90854a8cddd53c0ffc987f75abcee)
Diffstat (limited to 'python/vyos/config_mgmt.py')
-rw-r--r-- | python/vyos/config_mgmt.py | 20 |
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 # |