diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-06-24 07:11:41 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-07-08 08:26:11 -0500 |
| commit | 816834bcad0a536930dd1bc4a35ef6b8537f3522 (patch) | |
| tree | 96dd6223551972b0048518154d26f5533b513f28 /python | |
| parent | 170244db88f76e42aeceb0b971246327fe079e19 (diff) | |
| download | vyos-1x-816834bcad0a536930dd1bc4a35ef6b8537f3522.tar.gz vyos-1x-816834bcad0a536930dd1bc4a35ef6b8537f3522.zip | |
T7499: use direct request to vyconfd to avoid re-validating
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/vyconf_session.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/python/vyos/vyconf_session.py b/python/vyos/vyconf_session.py index 3f3f3957b..b42266793 100644 --- a/python/vyos/vyconf_session.py +++ b/python/vyos/vyconf_session.py @@ -189,6 +189,33 @@ class VyconfSession: return self.output(out), out.status @raise_exception + @config_mode + def merge_config( + self, file: str, migrate: bool = False, destructive: bool = False + ) -> tuple[str, int]: + # pylint: disable=consider-using-with + if migrate: + tmp = tempfile.NamedTemporaryFile() + shutil.copy2(file, tmp.name) + config_migrate = ConfigMigrate(tmp.name) + try: + config_migrate.run() + except ConfigMigrateError as e: + tmp.close() + return repr(e), 1 + file = tmp.name + else: + tmp = '' + + out = vyconf_client.send_request( + 'merge', token=self.__token, location=file, destructive=destructive + ) + if tmp: + tmp.close() + + return self.output(out), out.status + + @raise_exception def save_config(self, file: str, append_version: bool = False) -> tuple[str, int]: out = vyconf_client.send_request('save', token=self.__token, location=file) if append_version: |
