napalm-automation-community / napalm-huawei-vrp

NAPALM Driver for Huawei VRP5/VRP8 Routers and Switches

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_lldp_neighbors_detail

mailorderbribes opened this issue · comments

def get_lldp_neighbors_detail(self):
results = {}
command = 'display lldp neighbor brief'
output = self.device.send_command(command)
lines = output.split("\n")
for line in lines:
# translate Huawai
skip_lines = ['local', '-----']
local_iface = line[:14].strip()
remote_port = line[39:65].strip().replace(" ", "")
remote_system_name = line[14:39].strip()
local_iface = local_iface.replace("XGE", "XGigabitEthernet")
remote_port = remote_port.replace("XGE", "XGigabitEthernet")

        if local_iface[:5].lower() not in skip_lines:
            if local_iface not in results:
                results[local_iface] = []

            neighbor_dict = dict()
            neighbor_dict['remote_port'] = py23_compat.text_type(remote_port)
            neighbor_dict['remote_system_name'] = py23_compat.text_type(remote_system_name)
            results[local_iface].append(neighbor_dict)
    return results

this is working for 10gig interfaces in NetBox.. i have no gig nor 40/100 gig interfaces active to test against.. is suspect that the replace statement needs to be expanded tot get them equal to the names in the config.

I wrote this as a start for use in netbox only..so see it as a partial implementation

If you need me to test on a couple of VRP devices i am glad to help out.. i am in no way a python developer :)

@mailorderbribes Thanks for your contribution.

Yes, I haven't supported get_lldp_neighbors_detail yet.

The next major release of huawei_vrp will be version 0.2.0 which will have support for get_lldp_neighbors_detail.

As for the interface name, I need to think about it, because I need to be consistent with other drivers in the community.

BTW. it is a good idea to combine NAPLAM with Netbox.I'm going to do some tests later

Keep in touch. Locus!

@tkspuk

As for the interface name, I need to think about it, because I need to be consistent with other drivers in the community.

In netbox the inconsistent naming between "get_interfaces" and "show lldp neighbor brief" is fixed in the ajax.

netbox-community/netbox@bb653e7#diff-fb6ece1e6bb6bceb3c46c184f7f6c45b

More in general the question could be:
does napalm (drivers) have to take care of fixing inconsistencies or the app using napalm
To my opinion the whole purpose of napalm is to have a generic programming interface which is device independent..

I am also mailorderbribes :) Couldnt test due to bumping napalm release and the issue i opened related to py23compat

Added in release: v1.0.0 - 2022-01-13