napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.26k stars 554 forks source link

get_arp_table method for ios does not return all vrfs. #1351

Open hfeixas opened 3 years ago

hfeixas commented 3 years ago

Description of Issue

When running get_arp_table() method ios devices we do not retrieve all of the arp tables. The method just executes the following when no vrf is passed:

    if vrf:
        command = "show arp vrf {} | exclude Incomplete".format(vrf)
    else:
        command = "show arp | exclude Incomplete"

Ideally in a multi vrf environment we would want to retrieve all vrfs, and cycle through the arp tables in a separate get_arp_table worker function which doesn't care about command.. Liike:

    arp_table = []
    if vrf:
        command = "show ip arp vrf {} | exclude Incomplete".format(vrf)
        arp_entries = self._get_arp_table(command)
        if arp_entries:
            arp_table.extend(arp_entries)
    else:
        vrfs = self._get_vrfs()
        for entry in vrfs: 
            command = "show ip arp vrf {} | exclude Incomplete".format(entry)
            arp_entries = self._get_arp_table(command)
            if arp_entries:
                arp_table.extend(arp_entries)
        command = "show ip arp | exclude Incomplete"
        arp_entries = self._get_arp_table(command)

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

(Place an x between the square brackets where applicable)

Setup

napalm version

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

napalm==3.2.0

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Cisco IOS Software, 2800 Software (C2800NM-ADVENTERPRISEK9-M), Version 15.1(4)M10, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2015 by Cisco Systems, Inc.
Compiled Tue 24-Mar-15 09:00 by prod_rel_team

ROM: System Bootstrap, Version 12.4(13r)T11, RELEASE SOFTWARE (fc1)

******** uptime is 43 weeks, 1 day, 4 hours, 21 minutes
System returned to ROM by power-on
System image file is "flash:c2800nm-adventerprisek9-mz.151-4.M10.bin"
Last reload type: Normal Reload

This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco 2811 (revision 1.0) with 512000K/12288K bytes of memory.
Processor board ID *************
2 FastEthernet interfaces
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity enabled.
191K bytes of non-volatile configuration memory.
126976K bytes of ATA CompactFlash (Read/Write)

License Info:

License UDI:

-------------------------------------------------
Device#   PID                   SN
-------------------------------------------------
*0        CISCO2811             **************     

Configuration register is 0x2102
mirceaulinic commented 3 years ago

Thanks for this report @hfeixas. As you already have some working code, would you mind opening a PR to fix this?

hfeixas commented 3 years ago

Sure, its open: https://github.com/napalm-automation/napalm/pull/1361/files