diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2017-04-25 22:50:35 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-25 22:50:35 +0530 |
commit | 6ada5cc07416713ee20073b66f242ec935549ada (patch) | |
tree | 05f91a4dae2c82dfe8e2a957cb60af196539c094 | |
parent | f20cd780a43b3c73fb4a3bd3491f504c99f5eb62 (diff) | |
download | ansible-6ada5cc07416713ee20073b66f242ec935549ada.tar.gz |
Fixes #23960 junos_config fail with config in xml (#23962) (#23978)
If config is in xml format append it to <configuration>
tag as a instance of Element class.
(cherry picked from commit 15c19367d6e49e18d578c5868ff7733bfe5559f2)
-rw-r--r-- | lib/ansible/module_utils/junos.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 6ba0301893..f22dc7c395 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -18,7 +18,7 @@ # from contextlib import contextmanager -from xml.etree.ElementTree import Element, SubElement +from xml.etree.ElementTree import Element, SubElement, fromstring from ansible.module_utils.basic import env_fallback, return_values from ansible.module_utils.netconf import send_request, children @@ -108,10 +108,12 @@ def load_configuration(module, candidate=None, action='merge', rollback=None, fo cfg = SubElement(obj, lookup[format]) if isinstance(candidate, string_types): - cfg.text = candidate + if format == 'xml': + cfg.append(fromstring(candidate)) + else: + cfg.text = candidate else: cfg.append(candidate) - return send_request(module, obj) def get_configuration(module, compare=False, format='xml', rollback='0'): |