summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-06-02 16:06:52 +0300
committerGitHub <noreply@github.com>2023-06-02 16:06:52 +0300
commitb8a3dc506b7bd83a0a0fcb7981571eeeb8eedf64 (patch)
tree57149092bdf8f04939ee50f7d094ed57eada0f8e
parent6dd683f3e7a966bf0124444b746ab4a223bbe104 (diff)
parent362ece3add2771bf412131a306fd0c0cfa04c16c (diff)
downloadvyos-1x-b8a3dc506b7bd83a0a0fcb7981571eeeb8eedf64.tar.gz
vyos-1x-b8a3dc506b7bd83a0a0fcb7981571eeeb8eedf64.zip
Merge pull request #2023 from jestabro/error-passing
configtree: T5251: catch/raise errors in functions delete and delete_value
-rw-r--r--python/vyos/configtree.py13
-rwxr-xr-xsrc/migration-scripts/system/18-to-193
2 files changed, 11 insertions, 5 deletions
diff --git a/python/vyos/configtree.py b/python/vyos/configtree.py
index 19b9838d4..d0cd87464 100644
--- a/python/vyos/configtree.py
+++ b/python/vyos/configtree.py
@@ -201,7 +201,9 @@ class ConfigTree(object):
check_path(path)
path_str = " ".join(map(str, path)).encode()
- self.__delete(self.__config, path_str)
+ res = self.__delete(self.__config, path_str)
+ if (res != 0):
+ raise ConfigTreeError(f"Path doesn't exist: {path}")
if self.__migration:
print(f"- op: delete path: {path}")
@@ -210,7 +212,14 @@ class ConfigTree(object):
check_path(path)
path_str = " ".join(map(str, path)).encode()
- self.__delete_value(self.__config, path_str, value.encode())
+ res = self.__delete_value(self.__config, path_str, value.encode())
+ if (res != 0):
+ if res == 1:
+ raise ConfigTreeError(f"Path doesn't exist: {path}")
+ elif res == 2:
+ raise ConfigTreeError(f"Value doesn't exist: '{value}'")
+ else:
+ raise ConfigTreeError()
if self.__migration:
print(f"- op: delete_value path: {path} value: {value}")
diff --git a/src/migration-scripts/system/18-to-19 b/src/migration-scripts/system/18-to-19
index fd0e15d42..38479d222 100755
--- a/src/migration-scripts/system/18-to-19
+++ b/src/migration-scripts/system/18-to-19
@@ -92,9 +92,6 @@ else:
for intf in dhcp_interfaces:
config.set(base + ['name-servers-dhcp'], value=intf, replace=False)
- # delete old node
- config.delete(base + ['disable-dhcp-nameservers'])
-
try:
with open(file_name, 'w') as f:
f.write(config.to_string())