Skip to content

Inconsistent key formatting for functions utilizing 'parse_intf_section' #2146

Open
@dyermitch

Description

@dyermitch

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions