Fix junos_command py3 related issues (#36782)

Fixes #36204

*  tostring() input string shoulb be in byte string format
*  to_ele() input is required in unicode format
This commit is contained in:
Ganesh Nalawade 2018-03-01 12:09:11 +05:30 committed by GitHub
commit 41d75783b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 6 deletions

View file

@ -27,7 +27,7 @@
#
import sys
from ansible.module_utils._text import to_text, to_native
from ansible.module_utils._text import to_text, to_bytes
from ansible.module_utils.connection import Connection, ConnectionError
try:
@ -67,9 +67,9 @@ class NetconfConnection(Connection):
response = self._exec_jsonrpc(name, *args, **kwargs)
if 'error' in response:
rpc_error = response['error'].get('data')
return self.parse_rpc_error(to_native(rpc_error, errors='surrogate_then_replace'))
return self.parse_rpc_error(to_bytes(rpc_error, errors='surrogate_then_replace'))
return fromstring(to_native(response['result'], errors='surrogate_then_replace'))
return fromstring(to_bytes(response['result'], errors='surrogate_then_replace'))
def parse_rpc_error(self, rpc_error):
if self.check_rc: