diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2017-04-27 13:16:40 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-27 13:16:40 +0530 |
commit | 7d710882a8103436d11f84da90bbac3e8d195399 (patch) | |
tree | 38a98b4ac30ca2b3be1e1806a14713b2d484fc28 | |
parent | 3185ec94c5aa1920e8b4c8df625dbdca37bdb96d (diff) | |
download | ansible-7d710882a8103436d11f84da90bbac3e8d195399.tar.gz |
Fix exception issue in junos_config (#24049)
ParseError execption is added to ElementTree
in py2.7. Prior to py2.7 need catch ExpatError
execption
-rw-r--r-- | lib/ansible/modules/network/junos/junos_config.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py index 9f49e14d38..a335e1e318 100644 --- a/lib/ansible/modules/network/junos/junos_config.py +++ b/lib/ansible/modules/network/junos/junos_config.py @@ -185,6 +185,7 @@ backup_path: """ import re import json +import sys from xml.etree import ElementTree @@ -195,6 +196,12 @@ from ansible.module_utils.junos import check_args as junos_check_args from ansible.module_utils.netconf import send_request from ansible.module_utils.six import string_types +if sys.version < (2, 7): + from xml.parsers.expat import ExpatError + ParseError = ExpatError +else: + ParseError = ElementTree.ParseError + USE_PERSISTENT_CONNECTION = True DEFAULT_COMMENT = 'configured by junos_config' @@ -217,7 +224,7 @@ def guess_format(config): try: ElementTree.fromstring(config) return 'xml' - except ElementTree.ParseError: + except ParseError: pass if config.startswith('set') or config.startswith('delete'): |