diff options
author | John Estabrook <jestabro@vyos.io> | 2023-09-07 13:31:45 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-09-07 13:31:45 -0500 |
commit | fd5517b38191f5bb5897912ef62f5a8d1156b7b3 (patch) | |
tree | 4e0fa8d5a0e97070bca4eb26b68e347e926b8aca /python/vyos | |
parent | 73ee99fac6c640a169f85723deefb0c2ece201ff (diff) | |
download | vyos-1x-fd5517b38191f5bb5897912ef62f5a8d1156b7b3.tar.gz vyos-1x-fd5517b38191f5bb5897912ef62f5a8d1156b7b3.zip |
config-mgmt: T5556: fix bug in revision to archive update
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/config_mgmt.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py index 9caf6da2b..dbf17ade4 100644 --- a/python/vyos/config_mgmt.py +++ b/python/vyos/config_mgmt.py @@ -25,6 +25,7 @@ from datetime import datetime from textwrap import dedent from pathlib import Path from tabulate import tabulate +from shutil import copy from vyos.config import Config from vyos.configtree import ConfigTree, ConfigTreeError, show_diff @@ -224,8 +225,6 @@ Proceed ?''' def rollback(self, rev: int, no_prompt: bool=False) -> Tuple[str,int]: """Reboot to config revision 'rev'. """ - from shutil import copy - msg = '' if not self._check_revision_number(rev): @@ -475,20 +474,20 @@ Proceed ?''' conf_file.chmod(0o644) def _archive_active_config(self) -> bool: - use_tmp = (boot_configuration_complete() or not - os.path.isfile(archive_config_file)) + save_to_tmp = (boot_configuration_complete() or not + os.path.isfile(archive_config_file)) mask = os.umask(0o113) - if use_tmp: - ext = os.getpid() - cmp_saved = f'/tmp/config.boot.{ext}' + ext = os.getpid() + cmp_saved = f'/tmp/config.boot.{ext}' + if save_to_tmp: save_config(cmp_saved) else: - cmp_saved = config_file + copy(config_file, cmp_saved) try: if cmp(cmp_saved, archive_config_file, shallow=False): - if use_tmp: os.unlink(cmp_saved) + os.unlink(cmp_saved) os.umask(mask) return False except FileNotFoundError: |