mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
If config is in xml format append it to <configuration> tag as a instance of Element class.
This commit is contained in:
parent
8e7c546ef9
commit
15c19367d6
1 changed files with 5 additions and 3 deletions
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
from contextlib import contextmanager
|
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.basic import env_fallback, return_values
|
||||||
from ansible.module_utils.netconf import send_request, children
|
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])
|
cfg = SubElement(obj, lookup[format])
|
||||||
|
|
||||||
if isinstance(candidate, string_types):
|
if isinstance(candidate, string_types):
|
||||||
|
if format == 'xml':
|
||||||
|
cfg.append(fromstring(candidate))
|
||||||
|
else:
|
||||||
cfg.text = candidate
|
cfg.text = candidate
|
||||||
else:
|
else:
|
||||||
cfg.append(candidate)
|
cfg.append(candidate)
|
||||||
|
|
||||||
return send_request(module, obj)
|
return send_request(module, obj)
|
||||||
|
|
||||||
def get_configuration(module, compare=False, format='xml', rollback='0'):
|
def get_configuration(module, compare=False, format='xml', rollback='0'):
|
||||||
|
|
Loading…
Reference in a new issue