Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent key formatting for functions utilizing 'parse_intf_section' #2146

Open
1 task done
dyermitch opened this issue Sep 10, 2024 · 0 comments
Open
1 task done

Comments

@dyermitch
Copy link

dyermitch commented Sep 10, 2024

Description of Issue/Question

Inconsistent key formatting, getter functions that make use of the 'parse_intf_section' function (get_interfaces) use the canonical naming scheme for keys rather than the raw output (get_interfaces_ip, get_interfaces_counters).

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

(Place an x between the square brackets where applicable)

  • Yes
  • [] No

Setup

napalm version

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

napalm==5.0.0

Network operating system version

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

nxos 9.3(10)

Steps to Reproduce the Issue

import napalm
from pprint import pprint as pp
import getpass
import argparse

parser = argparse.ArgumentParser()

parser.add_argument("-d", "--device", help = "Device to gather info from")
parser.add_argument("-u", "--user", help = "User to connect to device with", default=getpass.getuser())

args = parser.parse_args()

def gather_device_info(host, user):
    try:
        p = getpass.getpass()
    except Exception as error:
        print('ERROR', error)
    else:
        driver = napalm.get_network_driver('nxos_ssh')
        device = driver(host, user)
        device.open() 
        facts = device.get_facts()   
        vrfs = device.get_network_instances()
        ips = device.get_interfaces_ip()
        ints = device.get_interfaces()
        device.close()
        
        pp(ips['loopback0'])
        pp(ints['loopback0'])  

gather_device_info(args.device, args.user)

Error Traceback

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

Password: 
{'ipv4': {'1.1.1.1': {'prefix_length': 32}}}
Traceback (most recent call last):
  File "nxos_ssh_test.py", line 32, in <module>
    gather_device_info(args.device, args.user)
  File "nxos_ssh_test.py", line 30, in gather_device_info
    pp(ints['loopback0'])        
       ~~~~^^^^^^^^^^^^^
KeyError: 'loopback0'
dyermitch pushed a commit to dyermitch/napalm that referenced this issue Sep 10, 2024
Signed-off-by: mdyer <dyer25@llnl.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant