mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 18:04:02 -07:00
Fix rollback option in cli_config module (#44834)
* Fix rollback option in cli_config module * Update rollback flag in cliconf plugins * Add rollback api for junos cliconf plugin * Update doc * Update doc
This commit is contained in:
parent
a5b02d6c7c
commit
eb9c75caad
6 changed files with 67 additions and 13 deletions
|
@ -307,6 +307,15 @@ class CliconfBase(AnsiblePlugin):
|
|||
"""
|
||||
return self._connection.method_not_found("discard_changes is not supported by network_os %s" % self._play_context.network_os)
|
||||
|
||||
def rollback(self, rollback_id, commit=True):
|
||||
"""
|
||||
|
||||
:param rollback_id: The commit id to which configuration should be rollbacked
|
||||
:param commit: Flag to indicate if changes should be committed or not
|
||||
:return: Returns diff between before and after change.
|
||||
"""
|
||||
pass
|
||||
|
||||
def copy_file(self, source=None, destination=None, proto='scp', timeout=30):
|
||||
"""Copies file over scp/sftp to remote device
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ class Cliconf(CliconfBase):
|
|||
return {
|
||||
'supports_diff_replace': True,
|
||||
'supports_commit': True if self.supports_sessions else False,
|
||||
'supports_rollback': True if self.supports_sessions else False,
|
||||
'supports_rollback': False,
|
||||
'supports_defaults': False,
|
||||
'supports_onbox_diff': True if self.supports_sessions else False,
|
||||
'supports_commit_comment': False,
|
||||
|
|
|
@ -188,7 +188,7 @@ class Cliconf(CliconfBase):
|
|||
return {
|
||||
'supports_diff_replace': False,
|
||||
'supports_commit': True,
|
||||
'supports_rollback': True,
|
||||
'supports_rollback': False,
|
||||
'supports_defaults': False,
|
||||
'supports_onbox_diff': True,
|
||||
'supports_commit_comment': True,
|
||||
|
|
|
@ -174,6 +174,17 @@ class Cliconf(CliconfBase):
|
|||
|
||||
return resp
|
||||
|
||||
@configure
|
||||
def rollback(self, rollback_id, commit=True):
|
||||
resp = {}
|
||||
self.send_command('rollback %s' % int(rollback_id))
|
||||
resp['diff'] = self.compare_configuration()
|
||||
if commit:
|
||||
self.commit()
|
||||
else:
|
||||
self.discard_changes()
|
||||
return resp
|
||||
|
||||
def get_diff(self, rollback_id=None):
|
||||
diff = {'config_diff': None}
|
||||
response = self.compare_configuration(rollback_id=rollback_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue