mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Netconf bytes fixes (#41607)
* Solve some bytes issues on iosxr * Solve some bytes issues in junos * Do the correct thing with tostring based on lxml or not
This commit is contained in:
@@ -104,15 +104,10 @@ diff.prepared:
|
||||
import collections
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -165,15 +165,15 @@ import shlex
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_configuration, get_connection, get_capabilities
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_configuration, get_connection, get_capabilities, tostring
|
||||
from ansible.module_utils.network.common.parsing import Conditional, FailedConditionalError
|
||||
from ansible.module_utils.six import string_types, iteritems
|
||||
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
from lxml.etree import Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
try:
|
||||
import jxmlease
|
||||
@@ -233,7 +233,7 @@ def rpc(module, items):
|
||||
if fetch_config:
|
||||
reply = get_configuration(module, format=xattrs['format'])
|
||||
else:
|
||||
reply = exec_rpc(module, to_text(tostring(element), errors='surrogate_then_replace'), ignore_warning=False)
|
||||
reply = exec_rpc(module, tostring(element), ignore_warning=False)
|
||||
|
||||
if xattrs['format'] == 'text':
|
||||
if fetch_config:
|
||||
|
||||
@@ -182,7 +182,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.junos.junos import get_diff, load_config, get_configuration
|
||||
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, tostring
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_native, to_text
|
||||
|
||||
|
||||
@@ -81,16 +81,16 @@ ansible_facts:
|
||||
"""
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param, tostring
|
||||
from ansible.module_utils.network.junos.junos import get_configuration, get_connection
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
from lxml.etree import Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
try:
|
||||
from jnpr.junos import Device
|
||||
|
||||
@@ -195,14 +195,14 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.common.utils import conditional
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config, to_param_list
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
from lxml.etree import Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
@@ -139,15 +139,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config, to_param_list
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -106,15 +106,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config, to_param_list
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -164,15 +164,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, to_param_list
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config, get_configuration
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -101,15 +101,10 @@ diff.prepared:
|
||||
import collections
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -97,14 +97,9 @@ import collections
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, tostring
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -142,15 +142,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, to_param_list
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -95,15 +95,15 @@ output_lines:
|
||||
"""
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.netconf import exec_rpc
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
from lxml.etree import Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
|
||||
def main():
|
||||
@@ -153,7 +153,7 @@ def main():
|
||||
|
||||
reply = exec_rpc(module, tostring(element), ignore_warning=False)
|
||||
|
||||
result['xml'] = str(tostring(reply))
|
||||
result['xml'] = tostring(reply)
|
||||
|
||||
if module.params['output'] == 'text':
|
||||
data = reply.find('.//output')
|
||||
@@ -164,7 +164,7 @@ def main():
|
||||
result['output'] = module.from_json(reply.text.strip())
|
||||
|
||||
else:
|
||||
result['output'] = str(tostring(reply)).split('\n')
|
||||
result['output'] = tostring(reply).split('\n')
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
@@ -138,15 +138,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, to_param_list
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -109,15 +109,10 @@ diff.prepared:
|
||||
import collections
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -140,15 +140,15 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_connection
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, get_connection, tostring
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes
|
||||
from ansible.module_utils.network.junos.junos import load_config, locked_config
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
try:
|
||||
from lxml.etree import Element, SubElement, tostring
|
||||
from lxml.etree import Element, SubElement
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
|
||||
ROLES = ['operator', 'read-only', 'super-user', 'unauthorized']
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
@@ -115,15 +115,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, to_param_list
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
@@ -173,15 +173,10 @@ from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec
|
||||
from ansible.module_utils.network.junos.junos import junos_argument_spec, tostring
|
||||
from ansible.module_utils.network.junos.junos import load_config, map_params_to_obj, map_obj_to_ele, to_param_list
|
||||
from ansible.module_utils.network.junos.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
except ImportError:
|
||||
from xml.etree.ElementTree import tostring
|
||||
|
||||
USE_PERSISTENT_CONNECTION = True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user