summaryrefslogtreecommitdiff
path: root/lib/ansible/modules
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/modules')
-rw-r--r--lib/ansible/modules/network/junos/junos_banner.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_command.py8
-rw-r--r--lib/ansible/modules/network/junos/junos_config.py2
-rw-r--r--lib/ansible/modules/network/junos/junos_facts.py6
-rw-r--r--lib/ansible/modules/network/junos/junos_interface.py6
-rw-r--r--lib/ansible/modules/network/junos/junos_l2_interface.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_l3_interface.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_linkagg.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_lldp.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_lldp_interface.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_logging.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_rpc.py10
-rw-r--r--lib/ansible/modules/network/junos/junos_static_route.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_system.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_user.py6
-rw-r--r--lib/ansible/modules/network/junos/junos_vlan.py7
-rw-r--r--lib/ansible/modules/network/junos/junos_vrf.py7
17 files changed, 30 insertions, 85 deletions
diff --git a/lib/ansible/modules/network/junos/junos_banner.py b/lib/ansible/modules/network/junos/junos_banner.py
index a890c4d78b..aac07c2d88 100644
--- a/lib/ansible/modules/network/junos/junos_banner.py
+++ b/lib/ansible/modules/network/junos/junos_banner.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py
index fade2f4607..f8419f8fd6 100644
--- a/lib/ansible/modules/network/junos/junos_command.py
+++ b/lib/ansible/modules/network/junos/junos_command.py
@@ -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:
diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py
index c04ac5c6ee..1e918b38ce 100644
--- a/lib/ansible/modules/network/junos/junos_config.py
+++ b/lib/ansible/modules/network/junos/junos_config.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_facts.py b/lib/ansible/modules/network/junos/junos_facts.py
index 22bf248760..a15c134bff 100644
--- a/lib/ansible/modules/network/junos/junos_facts.py
+++ b/lib/ansible/modules/network/junos/junos_facts.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_interface.py b/lib/ansible/modules/network/junos/junos_interface.py
index 3a3950e2a2..bd06f7170b 100644
--- a/lib/ansible/modules/network/junos/junos_interface.py
+++ b/lib/ansible/modules/network/junos/junos_interface.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_l2_interface.py b/lib/ansible/modules/network/junos/junos_l2_interface.py
index d9068301ec..1ad0a524ff 100644
--- a/lib/ansible/modules/network/junos/junos_l2_interface.py
+++ b/lib/ansible/modules/network/junos/junos_l2_interface.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_l3_interface.py b/lib/ansible/modules/network/junos/junos_l3_interface.py
index a4a6830b6f..f4cf98721f 100644
--- a/lib/ansible/modules/network/junos/junos_l3_interface.py
+++ b/lib/ansible/modules/network/junos/junos_l3_interface.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_linkagg.py b/lib/ansible/modules/network/junos/junos_linkagg.py
index d66af100a5..7b251eb55f 100644
--- a/lib/ansible/modules/network/junos/junos_linkagg.py
+++ b/lib/ansible/modules/network/junos/junos_linkagg.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_lldp.py b/lib/ansible/modules/network/junos/junos_lldp.py
index 05c05854f9..80840145ab 100644
--- a/lib/ansible/modules/network/junos/junos_lldp.py
+++ b/lib/ansible/modules/network/junos/junos_lldp.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_lldp_interface.py b/lib/ansible/modules/network/junos/junos_lldp_interface.py
index af4a7f5948..5e683c74f6 100644
--- a/lib/ansible/modules/network/junos/junos_lldp_interface.py
+++ b/lib/ansible/modules/network/junos/junos_lldp_interface.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_logging.py b/lib/ansible/modules/network/junos/junos_logging.py
index ec6540ea2d..60fe0c52d4 100644
--- a/lib/ansible/modules/network/junos/junos_logging.py
+++ b/lib/ansible/modules/network/junos/junos_logging.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_rpc.py b/lib/ansible/modules/network/junos/junos_rpc.py
index ac7f9ce16b..41c0413ee3 100644
--- a/lib/ansible/modules/network/junos/junos_rpc.py
+++ b/lib/ansible/modules/network/junos/junos_rpc.py
@@ -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)
diff --git a/lib/ansible/modules/network/junos/junos_static_route.py b/lib/ansible/modules/network/junos/junos_static_route.py
index 464dfe4640..e34dafd2c8 100644
--- a/lib/ansible/modules/network/junos/junos_static_route.py
+++ b/lib/ansible/modules/network/junos/junos_static_route.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_system.py b/lib/ansible/modules/network/junos/junos_system.py
index 2def0ec8b2..f8f7b4f68e 100644
--- a/lib/ansible/modules/network/junos/junos_system.py
+++ b/lib/ansible/modules/network/junos/junos_system.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_user.py b/lib/ansible/modules/network/junos/junos_user.py
index 94c9c9ab95..c5fe313bef 100644
--- a/lib/ansible/modules/network/junos/junos_user.py
+++ b/lib/ansible/modules/network/junos/junos_user.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_vlan.py b/lib/ansible/modules/network/junos/junos_vlan.py
index dda860518d..89a622b183 100644
--- a/lib/ansible/modules/network/junos/junos_vlan.py
+++ b/lib/ansible/modules/network/junos/junos_vlan.py
@@ -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
diff --git a/lib/ansible/modules/network/junos/junos_vrf.py b/lib/ansible/modules/network/junos/junos_vrf.py
index 685fe1e719..ef80edb637 100644
--- a/lib/ansible/modules/network/junos/junos_vrf.py
+++ b/lib/ansible/modules/network/junos/junos_vrf.py
@@ -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