Fix junos_config confirm timeout issue (#40238)
* Fix junos_config confirm timeout issue * Fix unit test
This commit is contained in:
parent
979f1e5ed1
commit
865f2c5990
2 changed files with 6 additions and 4 deletions
|
@ -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 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.network.junos.junos import junos_argument_spec, load_configuration, get_connection, tostring
|
||||||
from ansible.module_utils.six import string_types
|
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:
|
try:
|
||||||
from lxml.etree import Element, fromstring
|
from lxml.etree import Element, fromstring
|
||||||
|
@ -362,10 +362,11 @@ def main():
|
||||||
'comment': module.params['comment']
|
'comment': module.params['comment']
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.params['confirm'] > 0:
|
confirm = module.params['confirm']
|
||||||
|
if confirm > 0:
|
||||||
kwargs.update({
|
kwargs.update({
|
||||||
'confirm': True,
|
'confirm': True,
|
||||||
'confirm_timeout': module.params['confirm']
|
'confirm_timeout': to_text(confirm, errors='surrogate_then_replace')
|
||||||
})
|
})
|
||||||
commit_configuration(module, **kwargs)
|
commit_configuration(module, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -23,6 +23,7 @@ __metaclass__ = type
|
||||||
from ansible.compat.tests.mock import patch
|
from ansible.compat.tests.mock import patch
|
||||||
from ansible.modules.network.junos import junos_config
|
from ansible.modules.network.junos import junos_config
|
||||||
from units.modules.utils import set_module_args
|
from units.modules.utils import set_module_args
|
||||||
|
from ansible.module_utils._text import to_text
|
||||||
from .junos_module import TestJunosModule, load_fixture
|
from .junos_module import TestJunosModule, load_fixture
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ class TestJunosConfigModule(TestJunosModule):
|
||||||
set_module_args(dict(src=src, confirm=40))
|
set_module_args(dict(src=src, confirm=40))
|
||||||
self.execute_module(changed=True)
|
self.execute_module(changed=True)
|
||||||
args, kwargs = self.commit_configuration.call_args
|
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):
|
def test_junos_config_rollback(self):
|
||||||
rollback = 10
|
rollback = 10
|
||||||
|
|
Loading…
Reference in a new issue