diff options
| author | lucaelin <git@luca.lsys.ac> | 2026-02-23 13:25:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-23 12:25:35 +0000 |
| commit | e539028c2f9d062e7684abda5dd32affd92e9f08 (patch) | |
| tree | 26bdccd9ae304c9d4eef843e60eb61f7ad54e3df /plugins/cliconf | |
| parent | 8d96e7a700d30667c594ab7880538451f60d7fb4 (diff) | |
| download | vyos.vyos-e539028c2f9d062e7684abda5dd32affd92e9f08.tar.gz vyos.vyos-e539028c2f9d062e7684abda5dd32affd92e9f08.zip | |
add commit-confirm options to vyos_config (#229)
* added vyos_config confirm options
* fix: update commit comment to match main
* fix: documentation example for automatic confirm
* fix: add tests for commit confirm and confirm_timeout options
* fix: add config_confirm changelog fragment
* fix: lint missing diff parameter for edit_config
* fix: add commit confirm integration test
---------
Co-authored-by: omnom62 <75066712+omnom62@users.noreply.github.com>
Diffstat (limited to 'plugins/cliconf')
| -rw-r--r-- | plugins/cliconf/vyos.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/cliconf/vyos.py b/plugins/cliconf/vyos.py index c35ff1ec..17fcdf24 100644 --- a/plugins/cliconf/vyos.py +++ b/plugins/cliconf/vyos.py @@ -122,7 +122,9 @@ class Cliconf(CliconfBase): out = self.send_command(command) return out - def edit_config(self, candidate=None, commit=True, replace=None, comment=None): + def edit_config( + self, candidate=None, commit=True, replace=None, diff=False, comment=None, confirm=None + ): resp = {} operations = self.get_device_operations() self.check_edit_config_capability(operations, candidate, commit, replace, comment) @@ -143,7 +145,7 @@ class Cliconf(CliconfBase): if diff_config: if commit: try: - self.commit(comment) + self.commit(comment, confirm) except AnsibleConnectionFailure as e: msg = "commit failed: %s" % e.message self.discard_changes() @@ -191,12 +193,19 @@ class Cliconf(CliconfBase): check_all=check_all, ) - def commit(self, comment=None): - if comment: - command = 'commit comment "{0}"'.format(comment) + def commit(self, comment=None, confirm=None): + if confirm: + if comment: + command = 'commit-confirm {0} comment "{1}"'.format(confirm, comment) + else: + command = 'commit-confirm {0}'.format(confirm) + self.send_command(command, "Proceed?", "\n") else: - command = "commit" - self.send_command(command) + if comment: + command = 'commit comment "{0}"'.format(comment) + else: + command = "commit" + self.send_command(command) def discard_changes(self): self.send_command("exit discard") |
