summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils
diff options
context:
space:
mode:
authorGanesh Nalawade <ganesh634@gmail.com>2017-09-01 15:42:16 +0530
committerGitHub <noreply@github.com>2017-09-01 15:42:16 +0530
commit20e47b6132260467efe3328750209f6fa060432a (patch)
tree7cf5c41d4bc99fb5a6da36415b657bf6bdf05c9b /lib/ansible/module_utils
parent9dc41ae578a53fe906ef685e322e8cbbd07a04f3 (diff)
downloadansible-20e47b6132260467efe3328750209f6fa060432a.tar.gz
Junos_config unicode (#23369) (#28913)
* Try to handle unicode output more sensibly * Appears I'm getting latin1 instead Ugh. (cherry picked from commit 689b93bf145a48bf641705a00c5d1996e3dc45dc)
Diffstat (limited to 'lib/ansible/module_utils')
-rw-r--r--lib/ansible/module_utils/junos.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py
index c68a44d15f..31bfe8a5d1 100644
--- a/lib/ansible/module_utils/junos.py
+++ b/lib/ansible/module_utils/junos.py
@@ -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):
@@ -183,7 +184,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)