summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-06-19 20:49:11 -0500
committerJohn Estabrook <jestabro@vyos.io>2024-06-26 15:45:19 -0500
commit9388f62783849854fb9ca9852b5dc285932cf562 (patch)
tree619dd44aeea5694e7bc4f00ead5d232f39f8cef5
parentad4f8312f6a341bb0ebdd40bb472746fad8d5d2a (diff)
downloadvyos-1x-9388f62783849854fb9ca9852b5dc285932cf562.tar.gz
vyos-1x-9388f62783849854fb9ca9852b5dc285932cf562.zip
migration: T6007: write configtree operations to log
-rw-r--r--python/vyos/configtree.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index afd6e030b..5775070e2 100644
--- a/python/vyos/configtree.py
+++ b/python/vyos/configtree.py
@@ -15,6 +15,7 @@
import os
import re
import json
+import logging
from ctypes import cdll, c_char_p, c_void_p, c_int, c_bool
@@ -161,6 +162,8 @@ class ConfigTree(object):
self.__version = ''
self.__migration = os.environ.get('VYOS_MIGRATION')
+ if self.__migration:
+ self.migration_log = logging.getLogger('vyos.migrate')
def __del__(self):
if self.__config is not None:
@@ -215,7 +218,7 @@ class ConfigTree(object):
self.__set_add_value(self.__config, path_str, str(value).encode())
if self.__migration:
- print(f"- op: set path: {path} value: {value} replace: {replace}")
+ self.migration_log.info(f"- op: set path: {path} value: {value} replace: {replace}")
def delete(self, path):
check_path(path)
@@ -226,7 +229,7 @@ class ConfigTree(object):
raise ConfigTreeError(f"Path doesn't exist: {path}")
if self.__migration:
- print(f"- op: delete path: {path}")
+ self.migration_log.info(f"- op: delete path: {path}")
def delete_value(self, path, value):
check_path(path)
@@ -242,7 +245,7 @@ class ConfigTree(object):
raise ConfigTreeError()
if self.__migration:
- print(f"- op: delete_value path: {path} value: {value}")
+ self.migration_log.info(f"- op: delete_value path: {path} value: {value}")
def rename(self, path, new_name):
check_path(path)
@@ -258,7 +261,7 @@ class ConfigTree(object):
raise ConfigTreeError("Path [{}] doesn't exist".format(path))
if self.__migration:
- print(f"- op: rename old_path: {path} new_path: {new_path}")
+ self.migration_log.info(f"- op: rename old_path: {path} new_path: {new_path}")
def copy(self, old_path, new_path):
check_path(old_path)
@@ -275,7 +278,7 @@ class ConfigTree(object):
raise ConfigTreeError(msg)
if self.__migration:
- print(f"- op: copy old_path: {old_path} new_path: {new_path}")
+ self.migration_log.info(f"- op: copy old_path: {old_path} new_path: {new_path}")
def exists(self, path):
check_path(path)