diff options
author | Yun Zheng Hu <hu@fox-it.com> | 2023-11-18 21:34:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-18 21:34:15 +0100 |
commit | a89243cfbfc90854a8cddd53c0ffc987f75abcee (patch) | |
tree | 1b7ec60e65611fcdc3bb8f5cd4da47c0aa6f5fab /python/vyos/config_mgmt.py | |
parent | ccc84c7bfc9ec9a8a044ed5f892d78854d5512f7 (diff) | |
download | vyos-1x-a89243cfbfc90854a8cddd53c0ffc987f75abcee.tar.gz vyos-1x-a89243cfbfc90854a8cddd53c0ffc987f75abcee.zip |
T2405: add Git support to commit-archive
T2405: add Git support to commit-archive
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 # |