Repository: napalm-automation/napalm

Issue:
get_lldp_neighbors_detail error on Juniper PTX
Hello

We recently encountered this error when calling get_lldp_neighbors_detail against a PTX5K.
$ napalm --user user --password pass --vendor junos 127.0.0.2 call get_lldp_neighbors_detail

```
2018-02-09 14:10:53,449 - napalm - ERROR - method - Failed: RpcError(severity: error, bad_element: get-lldp-interface-neighbors-information, message: error: syntax error
error: syntax error)

================= Traceback =================

Traceback (most recent call last):
  File "/usr/local/bin/napalm", line 11, in <module>
    load_entry_point('napalm==2.3.0', 'console_scripts', 'napalm')()
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/clitools/cl_napalm.py", line 285, in main
    run_tests(args)
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/clitools/cl_napalm.py", line 268, in run_tests
    call_getter(device, args.method, **method_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/clitools/cl_napalm.py", line 27, in wrapper
    r = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/napalm/base/clitools/cl_napalm.py", line 238, in call_getter
    r = func(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/napalm/junos/junos.py", line 718, in get_lldp_neighbors_detail
    lldp_table.get(interface_name=interface)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/factory/optable.py", line 64, in get
    self.xml = getattr(self.RPC, self.GET_RPC)(**rpc_args)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/rpcmeta.py", line 345, in _exec_rpc
    return self._junos.execute(rpc, **dec_args)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/decorators.py", line 63, in wrapper
    result = function(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/decorators.py", line 31, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 790, in execute
    errs=ex)
jnpr.junos.exception.RpcError: RpcError(severity: error, bad_element: get-lldp-interface-neighbors-information, message: error: syntax error
error: syntax error)
```

We were able to fix the error by making the following adjustments to:
/usr/local/lib/python2.7/dist-packages/napalm/junos/junos.py
```

 708         lldp_table.GET_RPC = 'get-lldp-interface-neighbors'
 709       -  if self.device.facts.get('personality') not in ('MX', 'M', 'T')\
 709       +  if self.device.facts.get('personality') not in ('PTX', 'MX', 'M', 'T')\
 710            and self.device.facts.get('model') not in ('EX9208', 'QFX10008'):
 711             # Still need to confirm for QFX10002 and other EX series
 712             lldp_table.GET_RPC = 'get-lldp-interface-neighbors-information'
 713
 714         for interface in interfaces:
 715             if 'EX9208' in self.device.facts.get('model'):
 716                 lldp_table.get(interface_device=interface)
 717          -  elif self.device.facts.get('personality') not in ('MX', 'M', 'T'):
 717          +  elif self.device.facts.get('personality') not in ('PTX', 'MX', 'M', 'T'):
 718                 lldp_table.get(interface_name=interface)
 719             else:

```
Not sure if this has been previously submitted or not but wanted to make a request. 

Thank you


Discussion:
Oh, nice. Could you send a PR?
Hey @bplimp thanks for reporting this. What @dbarrosop said: can you please put you patch in a PR? Cheers.

Resolving patch:
diff --git a/napalm/junos/junos.py b/napalm/junos/junos.py
--- a/napalm/junos/junos.py
+++ b/napalm/junos/junos.py
@@ -706,7 +706,7 @@ def get_lldp_neighbors_detail(self, interface=''):
         # Exceptions:
         # EX9208    personality = SWITCH    RPC: <get-lldp-interface-neighbors><interface-device>
         lldp_table.GET_RPC = 'get-lldp-interface-neighbors'
-        if self.device.facts.get('personality') not in ('MX', 'M', 'T')\
+        if self.device.facts.get('personality') not in ('MX', 'M', 'PTX', 'T')\
            and self.device.facts.get('model') not in ('EX9208', 'QFX10008'):
             # Still need to confirm for QFX10002 and other EX series
             lldp_table.GET_RPC = 'get-lldp-interface-neighbors-information'
@@ -714,7 +714,7 @@ def get_lldp_neighbors_detail(self, interface=''):
         for interface in interfaces:
             if 'EX9208' in self.device.facts.get('model'):
                 lldp_table.get(interface_device=interface)
-            elif self.device.facts.get('personality') not in ('MX', 'M', 'T'):
+            elif self.device.facts.get('personality') not in ('MX', 'M', 'PTX', 'T'):
                 lldp_table.get(interface_name=interface)
             else:
                 lldp_table.get(interface_device=interface)


Test patch: