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

optional_args doesn't have "huge_tree" as an available parameter for JunOS #2012

Closed
1 task done
architkhatri98 opened this issue Oct 3, 2023 · 2 comments
Closed
1 task done

Comments

@architkhatri98
Copy link
Contributor

architkhatri98 commented Oct 3, 2023

Description of Issue/Question

https://github.com/napalm-automation/napalm/blob/develop/napalm/junos/junos.py#L59
In the JunOSDriver() Constructor, there is no way to use huge_tree as an optional arg.
ncclient/ncclient#185 in this issue, whenever an xml node is greater than 10,000,000 bytes, an exception is raised lxml.etree.XMLSyntaxError: xmlSAX2Characters: huge text node
To fix this jnpr.junos.device.Device() introduced a huge_tree parameter here. Juniper/py-junos-eznc#975

But napalm doesn't support the huge_tree parameter yet. Due to this, I am seeing the same exception raised whenever I call get_config()

Note: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

4.10

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Junos 21.2R3-S5.4

Steps to Reproduce the Issue

device.get_config()

Error Traceback

(Paste the complete traceback of the exception between quotes below)

INFO:ncclient.transport.ssh:[host 127.0.0.1 session-id 91995] Received message from host
/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/device.py:857: RuntimeWarning: An unknown exception occurred - please report.
  warnings.warn(
Traceback (most recent call last):
  File "test_junos.py", line 18, in <module>
    current_config = device.get_config()
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/olympus_nqa/Device.py", line 1751, in get_config
    return executor(retrieve=retrieve)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/olympus_nqa/Device.py", line 179, in _run
    return getattr(self.device, method)(*args, **kwargs)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/napalm/junos/junos.py", line 2448, in get_config
    config = self.device.rpc.get_config(filter_xml=None, options=options)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/rpcmeta.py", line 151, in get_config
    response = self._junos.execute(rpc, **kwargs)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/decorators.py", line 76, in wrapper
    return function(*args, **kwargs)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/decorators.py", line 31, in wrapper
    return function(*args, **kwargs)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/device.py", line 834, in execute
    rpc_rsp_e = self._rpc_reply(
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/decorators.py", line 117, in wrapper
    rsp = function(self, *args, **kwargs)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/jnpr/junos/device.py", line 1470, in _rpc_reply
    return self._conn.rpc(rpc_cmd_e, filter_xml)._NCElement__doc
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/ncclient/manager.py", line 246, in execute
    return cls(self._session,
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/ncclient/operations/third_party/juniper/rpc.py", line 52, in request
    return self._request(rpc)
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/ncclient/operations/rpc.py", line 365, in _request
    self._reply.parse()
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/ncclient/operations/rpc.py", line 161, in parse
    root = self._root = to_ele(self._raw, huge_tree=self._huge_tree) # The <rpc-reply> element
  File "/Users/arkhatri/.pyenv/versions/olympus/lib/python3.8/site-packages/ncclient/xml_.py", line 129, in to_ele
    return x if etree.iselement(x) else etree.fromstring(x.encode('UTF-8'), parser=_get_parser(huge_tree))
  File "src/lxml/etree.pyx", line 3257, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1916, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1803, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1144, in lxml.etree._BaseParser._parseDoc
  File "src/lxml/parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 728, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 657, in lxml.etree._raiseParseError
  File "<string>", line 496650
lxml.etree.XMLSyntaxError: xmlSAX2Characters: huge text node, line 496650, column 41 
@ktbyers
Copy link
Contributor

ktbyers commented Oct 3, 2023

@architkhatri98 Do you want to submit a pull-request to fix this?

@architkhatri98
Copy link
Contributor Author

@ktbyers yes, I've opened up a pull-request with the fix.
#2013

@mirceaulinic mirceaulinic added this to the APPROVED milestone Mar 25, 2024
mirceaulinic added a commit that referenced this issue Apr 10, 2024
…_junos

Add huge_tree as an optional_arg in junos to fix xml huge tree node #2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants