Fixes #37208
If check_mode is enabled instead of committing th config need to
discard all the chnages to cnadidate db
In case of cli to discard changes issue `rollback 0` command
and for netconf execute `discard-changes` rpc call
(cherry picked from commit 8eaa9cc938
)
This commit is contained in:
parent
ec59181a28
commit
f91cda4b02
3 changed files with 18 additions and 6 deletions
|
@ -180,9 +180,9 @@ def locked_config(module):
|
|||
unlock_configuration(module)
|
||||
|
||||
|
||||
def discard_changes(module, exit=False):
|
||||
def discard_changes(module):
|
||||
conn = get_connection(module)
|
||||
return conn.discard_changes(exit=exit)
|
||||
return conn.discard_changes()
|
||||
|
||||
|
||||
def get_diff(module, rollback='0'):
|
||||
|
|
|
@ -84,10 +84,8 @@ class Cliconf(CliconfBase):
|
|||
command += b' and-quit'
|
||||
return self.send_command(command)
|
||||
|
||||
def discard_changes(self, rollback_id=None):
|
||||
command = b'rollback'
|
||||
if rollback_id is not None:
|
||||
command += b' %s' % int(rollback_id)
|
||||
def discard_changes(self):
|
||||
command = b'rollback 0'
|
||||
for cmd in chain(to_list(command), b'exit'):
|
||||
self.send_command(cmd)
|
||||
|
||||
|
|
|
@ -78,6 +78,20 @@
|
|||
- "result.changed == true"
|
||||
- "'<message>this is my login banner</message>' in config.xml"
|
||||
|
||||
- name: check mode
|
||||
junos_banner:
|
||||
banner: login
|
||||
text: this is not the login banner you're looking for
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
check_mode: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.failed == false"
|
||||
|
||||
- name: delete login banner
|
||||
junos_banner:
|
||||
banner: login
|
||||
|
|
Loading…
Reference in a new issue