|
|
|
@ -35,19 +35,24 @@ import traceback
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import env_fallback
|
|
|
|
|
from ansible.module_utils.network.common.utils import to_list, ComplexList
|
|
|
|
|
from ansible.module_utils.connection import exec_command
|
|
|
|
|
from ansible.module_utils.connection import exec_command, ConnectionError
|
|
|
|
|
from ansible.module_utils.six import iteritems
|
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
|
from ansible.module_utils.network.common.netconf import NetconfConnection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from ncclient.xml_ import to_xml
|
|
|
|
|
from ncclient.xml_ import to_xml, new_ele_ns
|
|
|
|
|
HAS_NCCLIENT = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
HAS_NCCLIENT = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from lxml import etree
|
|
|
|
|
except ImportError:
|
|
|
|
|
from xml.etree import ElementTree as etree
|
|
|
|
|
|
|
|
|
|
_DEVICE_CLI_CONNECTION = None
|
|
|
|
|
_DEVICE_NC_CONNECTION = None
|
|
|
|
|
|
|
|
|
@ -343,6 +348,28 @@ def set_nc_config(module, xml_str):
|
|
|
|
|
return to_string(to_xml(out))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_nc_next(module, xml_str):
|
|
|
|
|
""" get_nc_next for exchange capability """
|
|
|
|
|
|
|
|
|
|
conn = get_nc_connection(module)
|
|
|
|
|
result = None
|
|
|
|
|
if xml_str is not None:
|
|
|
|
|
response = conn.get(xml_str, if_rpc_reply=True)
|
|
|
|
|
result = response.find('./*')
|
|
|
|
|
set_id = response.get('set-id')
|
|
|
|
|
fetch_node = new_ele_ns('get-next', 'http://www.huawei.com/netconf/capability/base/1.0', {'set-id': set_id})
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
next = conn.dispatch(etree.tostring(fetch_node))
|
|
|
|
|
if next is not None:
|
|
|
|
|
result.extend(next)
|
|
|
|
|
except ConnectionError:
|
|
|
|
|
break
|
|
|
|
|
if result is not None:
|
|
|
|
|
return etree.tostring(result)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_nc_config(module, xml_str):
|
|
|
|
|
""" get_config """
|
|
|
|
|
|
|
|
|
|