Fix junos_config confirm timeout issue (#40238) (#40255)

* Fix junos_config confirm timeout issue

* Fix unit test

* Update changelog

(cherry picked from commit 865f2c5990)
pull/40263/head
Ganesh Nalawade 7 years ago committed by GitHub
parent 9818636a7c
commit f5463f9099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix junos_config confirm timeout issue (https://github.com/ansible/ansible/pull/40238)

@ -199,7 +199,7 @@ from ansible.module_utils.network.junos.junos import get_diff, load_config, get_
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
from ansible.module_utils.network.junos.junos import junos_argument_spec, load_configuration, get_connection, tostring
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_native
from ansible.module_utils._text import to_native, to_text
try:
from lxml.etree import Element, fromstring
@ -377,10 +377,11 @@ def main():
'comment': module.params['comment']
}
if module.params['confirm'] > 0:
confirm = module.params['confirm']
if confirm > 0:
kwargs.update({
'confirm': True,
'confirm_timeout': module.params['confirm']
'confirm_timeout': to_text(confirm, errors='surrogate_then_replace')
})
commit_configuration(module, **kwargs)
else:

@ -23,6 +23,7 @@ __metaclass__ = type
from ansible.compat.tests.mock import patch
from ansible.modules.network.junos import junos_config
from units.modules.utils import set_module_args
from ansible.module_utils._text import to_text
from .junos_module import TestJunosModule, load_fixture
@ -118,7 +119,7 @@ class TestJunosConfigModule(TestJunosModule):
set_module_args(dict(src=src, confirm=40))
self.execute_module(changed=True)
args, kwargs = self.commit_configuration.call_args
self.assertEqual(kwargs['confirm_timeout'], 40)
self.assertEqual(kwargs['confirm_timeout'], to_text(40))
def test_junos_config_rollback(self):
rollback = 10

Loading…
Cancel
Save