Skip to content

Issue in runner.py [ lines 104-120 ] - Unable to Parse RPC replies from Junos19.2 #121

@SauravMar

Description

@SauravMar

I have been trying to use yang-explorer with Juniper MX series router with Junos version 19.2.

Steps:

  • Manage Models -> Select Device Profile

Output:

  • UI shows a dialog box displaying "Something went wrong, returned errored response !!"
  • In the server logs, I am getting:

ERROR:django.request:Internal Server Error: /explorer/schema
Traceback (most recent call last):
File "/xxx/yang-explorer/v/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/xxx/yang-explorer/server/explorer/views.py", line 297, in schema_handler
return get_schema(request, req)
File "/xxx/yang-explorer/server/explorer/utils/schema.py", line 70, in get_schema
xml = Adapter.run_netconf(request.user.username, device, rpc_xml)
File "/xxx/yang-explorer/server/explorer/utils/adapter.py", line 113, in run_netconf
return session.run(rpc, lock)
File "/xxx/yang-explorer/server/explorer/utils/runner.py", line 105, in run
response = self.handle.get(data).xml

AttributeError: 'NCElement' object has no attribute 'xml'

Root Cause:

  • RPC replies from Junos does not contain XML attribute.

Fix:

  • Instead of response = self.handle.<get,get_config,edit_config,dispatch>(data).xml, we can put a try-except block:
    try:
    response = self.handle.<get,get_config,edit_config,dispatch>(data).xml
    except:
    response = str(self.handle.<get,get_config,edit_config,dispatch>(data))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions