summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-09-07 13:31:45 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-09-08 08:40:32 -0500
commitd75a7d17a98b30fea1140675849d76dffe5c61f2 (patch)
treed84b1d7f1ebae4dea3be43cbdb30f33dae2d2aaf
parentc35a66f327b09686344c63db2da8634b55f18d79 (diff)
downloadvyos-1x-d75a7d17a98b30fea1140675849d76dffe5c61f2.tar.gz
vyos-1x-d75a7d17a98b30fea1140675849d76dffe5c61f2.zip
config-mgmt: T5556: fix bug in revision to archive update
(cherry picked from commit fd5517b38191f5bb5897912ef62f5a8d1156b7b3)
-rw-r--r--python/vyos/config_mgmt.py17
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: