mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
Junos_config unicode (#23369)
* Try to handle unicode output more sensibly * Appears I'm getting latin1 instead Ugh.
This commit is contained in:
parent
1c61b9bae7
commit
689b93bf14
4 changed files with 8 additions and 8 deletions
|
@ -24,6 +24,7 @@ from ansible.module_utils.basic import env_fallback, return_values
|
|||
from ansible.module_utils.netconf import send_request, children
|
||||
from ansible.module_utils.netconf import discard_changes, validate
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_text
|
||||
|
||||
ACTIONS = frozenset(['merge', 'override', 'replace', 'update', 'set'])
|
||||
JSON_ACTIONS = frozenset(['merge', 'override', 'update'])
|
||||
|
@ -111,7 +112,7 @@ def load_configuration(module, candidate=None, action='merge', rollback=None, fo
|
|||
if format == 'xml':
|
||||
cfg.append(fromstring(candidate))
|
||||
else:
|
||||
cfg.text = candidate
|
||||
cfg.text = to_text(candidate, encoding='latin1')
|
||||
else:
|
||||
cfg.append(candidate)
|
||||
return send_request(module, obj)
|
||||
|
@ -163,7 +164,7 @@ def get_diff(module):
|
|||
reply = get_configuration(module, compare=True, format='text')
|
||||
output = reply.find('.//configuration-output')
|
||||
if output is not None:
|
||||
return output.text
|
||||
return to_text(output.text, encoding='latin1').strip()
|
||||
|
||||
def load_config(module, candidate, warnings, action='merge', commit=False, format='xml',
|
||||
comment=None, confirm=False, confirm_timeout=None):
|
||||
|
@ -180,7 +181,6 @@ def load_config(module, candidate, warnings, action='merge', commit=False, forma
|
|||
diff = get_diff(module)
|
||||
|
||||
if diff:
|
||||
diff = str(diff).strip()
|
||||
if commit:
|
||||
commit_configuration(module, confirm=confirm, comment=comment,
|
||||
confirm_timeout=confirm_timeout)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue