napalm-automation / napalm-junos

Apache License 2.0
22 stars 42 forks source link

get_lldp_neighbors_detail doesn't work with JUNOS EX 14.1X53-D25.2 #166

Closed bugdealer closed 7 years ago

bugdealer commented 7 years ago

Description of Issue/Question

I was tryring out get_lldp_neighbors_detail API on a Juniper EX switch but got following error. I also tried get_lldp_neighbors and it works fine. It seems like a PyEz problem but I'm not sure of that.

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

[x ] Yes [ ] No

Setup

napalm-junos version

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

napalm-junos==0.6.6

JunOS version

(Paste verbatim output from show version and haiku between quotes below)

Model: ex8208
Junos: 14.1X53-D25.2
JUNOS EX  Software Suite [14.1X53-D25.2]
JUNOS FIPS mode utilities [14.1X53-D25.2]
JUNOS Online Documentation [14.1X53-D25.2]
JUNOS EX 8200 Software Suite [14.1X53-D25.2]
JUNOS Web Management Platform Package [14.1X53-D25.2]

Error Traceback

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

Traceback (most recent call last):
  File "C:\Users\ADMIN\My Documents\LiClipse Workspace\test\utils\test.py", line 20, in <module>
    info = getattr(device,'get_lldp_neighbors_detail')()
  File "C:\Users\ADMIN\My Documents\LiClipse Workspace\test\napalm_junos\junos.py", line 549, in get_lldp_neighbors_detail
    lldp_table.get(interface_device=interface)
  File "C:\Python27\lib\site-packages\jnpr\junos\factory\optable.py", line 64, in get
    self.xml = getattr(self.RPC, self.GET_RPC)(**rpc_args)
  File "C:\Python27\lib\site-packages\jnpr\junos\rpcmeta.py", line 336, in _exec_rpc
    return self._junos.execute(rpc, **dec_args)
  File "C:\Python27\lib\site-packages\jnpr\junos\decorators.py", line 63, in wrapper
    result = function(*args, **kwargs)
  File "C:\Python27\lib\site-packages\jnpr\junos\decorators.py", line 31, in wrapper
    return function(*args, **kwargs)
  File "C:\Python27\lib\site-packages\jnpr\junos\device.py", line 732, in execute
    errs=ex)
jnpr.junos.exception.RpcError: RpcError(severity: error, bad_element: get-lldp-interface-neighbors, message: error: syntax error
error: syntax error)
mirceaulinic commented 7 years ago

Hi @bugdealer - get_lldp_neighbors and get_lldp_neighbors_detail work very different (that's a very special case on Juniper). Also from the CLI, if you need to details you need to execute show lldp neighbors interface <interface name>. This is the request failing in that case. Would you be able to provide the output of show lldp neighbors interface <interface name> | display xml rpc (any interface lldp enabled)? Thanks!

bugdealer commented 7 years ago

Hi @mirceaulinic, the output is

show lldp neighbors interface xe-0/0/3 | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/14.1X53/junos">
    <rpc>
        <get-lldp-interface-neighbors-information>
                <interface-name>xe-0/0/3.0</interface-name>
        </get-lldp-interface-neighbors-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>
bugdealer commented 7 years ago

Hi, @mirceaulinic according to https://apps.juniper.net/xmlapi/operTags.jsp (Junos 13.1 and later) and https://www.juniper.net/documentation/en_US/junos12.3/information-products/topic-collections/junos-xml-ref-oper/index.html (Junos 12.3) get lldp neighbor by interface rpc for EX Series, QFX Series, J Series and SRX Series would always be get-lldp-interface-neighbors-information , and rpc for M, MX, and T Series would always be get-lldp-interface-neighbors Bug fixed and tested on MX, QFX and EX devices. Will create pull request and please help approve.

bugdealer commented 7 years ago

Found out some older JunOS release(11.4R7 in my case ) does not support get-lldp-interface-neighbors-information rpc... How can we support such devices?

mirceaulinic commented 7 years ago

Hi @bugdealer - If if doesn't support get-lldp-interface-neighbors-information, what's the RPC in that case?

bugdealer commented 7 years ago
show lldp neighbors interface xe-0/0/38.0 | display xml rpc 
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.4R7/junos">
    <message>
        xml rpc equivalent of this command is not available.
    </message>
    <cli>
        <banner>{master:0}</banner>
    </cli>
</rpc-reply>

@mirceaulinic :( guess we can call napalm cli api and manually parse text output to corresponding return format

mirceaulinic commented 7 years ago

Yea, that's bad... we can't do more than that so let's use the cli method.

mirceaulinic commented 7 years ago

Closed via https://github.com/napalm-automation/napalm-junos/commit/b019279c9687d65068636f80e00722a8168d5411