for capability/exchange/1.0 (#60630)
* for capability/exchange/1.0 * for capability/exchange/1.0 * update for shippable * Update ce.py * Update ce.py
This commit is contained in:
parent
6fa8abf162
commit
28227c95a4
1 changed files with 29 additions and 2 deletions
|
@ -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 """
|
||||
|
||||
|
|
Loading…
Reference in a new issue