napalm-huawei-vrp icon indicating copy to clipboard operation
napalm-huawei-vrp copied to clipboard

get_lldp_neighbors_detail

Open mailorderbribes opened this issue 4 years ago • 3 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 avatar May 02 '20 13:05 mailorderbribes

@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 avatar May 02 '20 16:05 tkspuk

@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.

https://github.com/netbox-community/netbox/commit/bb653e733cb8b70fd3eabca8867954792df03844#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..

mailorderbribes avatar May 02 '20 20:05 mailorderbribes

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

i4networks avatar May 19 '20 12:05 i4networks

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

codingnetworksb avatar Dec 02 '23 14:12 codingnetworksb