Fix junos_config confirm timeout issue (#40238)

* Fix junos_config confirm timeout issue

* Fix unit test
This commit is contained in:
Ganesh Nalawade 2018-05-16 18:14:23 +05:30 committed by GitHub
parent 979f1e5ed1
commit 865f2c5990
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -184,7 +184,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
@ -362,10 +362,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:

View file

@ -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