Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception issue in junos_config #24066

Merged
merged 2 commits into from
Apr 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/ansible/modules/network/junos/junos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"""
import re
import json
import sys

from xml.etree import ElementTree

Expand All @@ -185,6 +186,12 @@
from ansible.module_utils.netconf import send_request
from ansible.module_utils.six import string_types

if sys.version_info < (2, 7):
from xml.parsers.expat import ExpatError
ParseError = ExpatError
else:
ParseError = ElementTree.ParseError

USE_PERSISTENT_CONNECTION = True
DEFAULT_COMMENT = 'configured by junos_config'

Expand All @@ -207,7 +214,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'):
Expand Down