napalm-automation / napalm-nxos

Apache License 2.0
9 stars 21 forks source link

napalm-nxos SSH testing #112

Closed ktbyers closed 7 years ago

ktbyers commented 7 years ago

Create new virtual environment

Activate virtual environment

source nxos_ssh_test/bin/activate

Install napalm libraries

pip install -q napalm-base pip install git+https://github.com/napalm-automation/napalm-nxos@nxos_ssh

If using napalm-ansible

git clone https://github.com/napalm-automation/napalm-ansible

Edit .ansible.cfg

[defaults]
# Add this line
library = /path/to/napalm-ansible/library

Test script for config operations

from __future__ import print_function
from napalm_base import get_network_driver
from getpass import getpass

driver = get_network_driver('nxos_ssh')
optional_args = {'port': 22}
device = driver(hostname='bogus.domain.com', username='admin', password=getpass(), 
                optional_args=optional_args)

device.open()
device.load_merge_candidate(filename='merge.conf')
print(device.compare_config())
#device.discard_config()
#device.commit_config()
device.close()

The following getter methods should also work:

get_users get_ntp_servers get_snmp_information
get_interfaces_ip get_interfaces get_ntp_peers get_config get_facts

Contributing unit test data

# gather the output of these show commands (remove any confidential information).
show run
show start
show ntp peers
show ipv6 interface
show ip interface
show ntp peers
show hostname
show hosts
show interface status
show version
show interface
itdependsnetworks commented 7 years ago

^^ Those plus these below should give feature parity with nxapi.

show ip arp
show ntp peer-status
show ip interface
show mac address-table
show ipv6 interface
show bgp sessions vrf all
jtdub commented 7 years ago

Here are my initial test results:

(nxos_ssh_test) ~/testing$ ./test.py
Password:
## TESTING NAPALM NXOS SSH on N7K-C7009 ##
  description NAPALM NEW CONFIG
## TESTING NAPALM NXOS SSH on N9K-C9272Q ##
  description NAPALM NEW CONFIG
## TESTING NAPALM NXOS SSH on N3K-C3172 ##
  description NAPALM NEW CONFIG
(nxos_ssh_test) ~/testing$ cat test.py
#!/usr/bin/env python

from __future__ import print_function
from napalm_base import get_network_driver
from getpass import getpass

devices = [{'hostname': 'N7009-1', 'chassis': 'N7K-C7009', 'config': 'n7k-merge.conf'},
        {'hostname': 'N9272-1', 'chassis': 'N9K-C9272Q', 'config': 'n9k-merge.conf'},
        {'hostname': 'N3172-2', 'chassis': 'N3K-C3172', 'config': 'n3k-merge.conf'}]

password = getpass()

driver = get_network_driver('nxos_ssh')
optional_args = {'port': 22}

for item in devices:
    print("## TESTING NAPALM NXOS SSH on {} ##".format(item['chassis']))
    device = driver(hostname=item['hostname'], username='admin', password=password,
                optional_args=optional_args)
    device.open()
    device.load_merge_candidate(filename=item['config'])
    print(device.compare_config())
    #device.get_users()
    #device.get_ntp_servers()
    #device.get_snmp_information()
    #device.get_interfaces_ip()
    #device.get_interfaces()
    #device.get_ntp_peers()
    #device.get_facts()
    device.close()
(nxos_ssh_test) ~/testing$ cat n7k-merge.conf
interface Ethernet4/48
  description NAPALM NEW CONFIG
(nxos_ssh_test) ~/testing$ cat n9k-merge.conf
interface Ethernet1/72
  description NAPALM NEW CONFIG
  switchport
  switchport mode trunk
  no shutdown
(nxos_ssh_test) ~/testing$ cat n3k-merge.conf
interface Ethernet1/54
  description NAPALM NEW CONFIG
mirceaulinic commented 7 years ago

I think we can close this one now.