summaryrefslogtreecommitdiff
path: root/python/vyos/configsession.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos/configsession.py')
-rw-r--r--python/vyos/configsession.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py
index 7af2cb333..50f93f890 100644
--- a/python/vyos/configsession.py
+++ b/python/vyos/configsession.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2025 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or modify it under the terms of
# the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -182,8 +182,9 @@ class ConfigSession(object):
self.__run_command([CLI_SHELL_API, 'setupSession'])
if vyconf_backend() and boot_configuration_complete():
- self._vyconf_session = VyconfSession(pid=session_id,
- on_error=ConfigSessionError)
+ self._vyconf_session = VyconfSession(
+ pid=session_id, on_error=ConfigSessionError
+ )
else:
self._vyconf_session = None
@@ -333,7 +334,7 @@ class ConfigSession(object):
if self._vyconf_session is None:
config_data = self.__run_command(SHOW_CONFIG + path)
else:
- config_data, _ = self._vyconf_session.show_config()
+ config_data, _ = self._vyconf_session.show_config(path)
if format == 'raw':
return config_data
@@ -342,7 +343,7 @@ class ConfigSession(object):
if self._vyconf_session is None:
out = self.__run_command(LOAD_CONFIG + [file_path])
else:
- out, _ = self._vyconf_session.load_config(file=file_path)
+ out, _ = self._vyconf_session.load_config(file_name=file_path)
return out
@@ -359,15 +360,18 @@ class ConfigSession(object):
if self._vyconf_session is None:
out = self.__run_command(MIGRATE_LOAD_CONFIG + [file_path])
else:
- out, _ = self._vyconf_session.load_config(file=file_path, migrate=True)
+ out, _ = self._vyconf_session.load_config(file_name=file_path, migrate=True)
return out
- def merge_config(self, file_path):
+ def merge_config(self, file_path, destructive=False):
if self._vyconf_session is None:
- out = self.__run_command(MERGE_CONFIG + [file_path])
+ destr = ['--destructive'] if destructive else []
+ out = self.__run_command(MERGE_CONFIG + [file_path] + destr)
else:
- out = 'unimplemented'
+ out, _ = self._vyconf_session.merge_config(
+ file_name=file_path, destructive=destructive
+ )
return out