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

pass on huge_tree to ncclient #975

Merged
merged 1 commit into from Nov 14, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion lib/jnpr/junos/console.py
Expand Up @@ -122,6 +122,7 @@ def __init__(self, **kvargs):
self._attempts = kvargs.get('attempts', 10)
self._gather_facts = kvargs.get('gather_facts', False)
self._fact_style = kvargs.get('fact_style', 'new')
self._huge_tree = kvargs.get('huge_tree', False)
if self._fact_style != 'new':
warnings.warn('fact-style %s will be removed in '
'a future release.' %
Expand Down Expand Up @@ -275,7 +276,8 @@ def _rpc_reply(self, rpc_cmd_e, *args, **kwargs):
if isinstance(rpc_cmd_e, etree._Element) else rpc_cmd_e
reply = self._tty.nc.rpc(rpc_cmd)
rpc_rsp_e = NCElement(reply,
self.junos_dev_handler.transform_reply()
self.junos_dev_handler.transform_reply(),
self._huge_tree
)._NCElement__doc
return rpc_rsp_e

Expand All @@ -290,6 +292,7 @@ def _tty_login(self):
tty_args['timeout'] = float(self._timeout)
tty_args['attempts'] = int(self._attempts)
tty_args['baud'] = self._baud
tty_args['huge_tree'] = self._huge_tree
if self._mode and self._mode.upper() == 'TELNET':
tty_args['host'] = self._hostname
tty_args['port'] = self._port
Expand Down
6 changes: 6 additions & 0 deletions lib/jnpr/junos/device.py
Expand Up @@ -1145,6 +1145,9 @@ def __init__(self, *vargs, **kvargs):
default is ``False`` to use DOM.
Select ``True`` to use SAX (if SAX input is provided).

:param bool huge_tree:
*OPTIONAL* parse XML with very deep trees and long text content.
default is ``False``.
"""

# ----------------------------------------
Expand All @@ -1160,6 +1163,7 @@ def __init__(self, *vargs, **kvargs):
self._auto_probe = kvargs.get('auto_probe', self.__class__.auto_probe)
self._fact_style = kvargs.get('fact_style', 'new')
self._use_filter = kvargs.get('use_filter', False)
self._huge_tree = kvargs.get('huge_tree', False)
if self._fact_style != 'new':
warnings.warn('fact-style %s will be removed in a future '
'release.' %
Expand Down Expand Up @@ -1339,6 +1343,8 @@ def open(self, *vargs, **kvargs):
cnx_err._orig = err
raise cnx_err

if self._huge_tree:
self._conn.huge_tree = True
self.connected = True

self._nc_transform = self.transform
Expand Down
1 change: 1 addition & 0 deletions lib/jnpr/junos/transport/tty.py
Expand Up @@ -82,6 +82,7 @@ def __init__(self, **kvargs):
self.cs_passwd = kvargs.get('cs_passwd')
self.login_attempts = kvargs.get('attempts') or self.LOGIN_RETRY
self.console_has_banner = kvargs.get('console_has_banner') or False
self._huge_tree = kvargs.get('huge_tree', False)

# misc setup
self.nc = tty_netconf(self)
Expand Down
6 changes: 4 additions & 2 deletions lib/jnpr/junos/transport/tty_netconf.py
Expand Up @@ -119,7 +119,7 @@ def rpc(self, cmd):

rsp = self._receive()
rsp = rsp.decode('utf-8') if isinstance(rsp, bytes) else rsp
reply = RPCReply(rsp)
reply = RPCReply(rsp, huge_tree=self._tty._huge_tree)
errors = reply.errors
if len(errors) > 1:
raise RPCError(to_ele(reply._raw), errs=errors)
Expand Down Expand Up @@ -161,8 +161,10 @@ def _receive(self):
rxbuf = [i.strip() for i in rxbuf if i.strip() != PY6.EMPTY_STR]
rcvd_data = PY6.NEW_LINE.join(rxbuf)
logger.debug('Received: \n%s' % rcvd_data)
parser = etree.XMLParser(remove_blank_text=True,
huge_tree=self._tty._huge_tree)
try:
etree.XML(rcvd_data)
etree.XML(rcvd_data, parser)
except XMLSyntaxError:
if _NETCONF_EOM in rcvd_data:
rcvd_data = rcvd_data[:rcvd_data.index(_NETCONF_EOM)]
Expand Down