Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from ggiesen/get-config
Browse files Browse the repository at this point in the history
Implement get_config() getter
  • Loading branch information
ggiesen authored Jun 16, 2020
2 parents 02b125d + 7b3eed3 commit b26350e
Show file tree
Hide file tree
Showing 12 changed files with 2,082 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NAPALM driver for Dell EMC Networking OS6 Operating System.
* cli
* get_interfaces_ip
* get_mac_address_table
* get_config
* get_vlans

### Missing APIs
Expand All @@ -42,7 +43,6 @@ NAPALM driver for Dell EMC Networking OS6 Operating System.
* traceroute
* get_users
* get_optics
* get_config
* get_network_instances
* get_firewall_policies
* get_ipv6_neighbors_table
Expand Down
48 changes: 47 additions & 1 deletion napalm_dellos6/dellos6.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
import socket
from ipaddress import IPv4Interface, IPv6Interface

import napalm_dellos6.dellos6_constants as D6C
from napalm.base import NetworkDriver
from napalm.base.exceptions import CommandErrorException, ConnectionClosedException
from napalm.base.helpers import canonical_interface_name, mac, textfsm_extractor
from napalm.base.helpers import (
canonical_interface_name,
mac,
sanitize_configs,
textfsm_extractor,
)

from napalm_dellos6.dellos6_canonical_map import dellos6_interfaces

Expand Down Expand Up @@ -1378,3 +1384,43 @@ def get_mac_address_table(self):
}
)
return table

def get_config(self, retrieve="all", full=False, sanitized=False):
"""
Return the configuration of a device.
Args:
retrieve(string): Which configuration type you want to populate, default is all of them.
The rest will be set to "".
full(bool): Retrieve all the configuration. For instance, on ios, "sh run all".
sanitized(bool): Remove secret data. Default: ``False``.
Returns:
The object returned is a dictionary with a key for each configuration store:
- running(string) - Representation of the native running configuration
- candidate(string) - Representation of the native candidate configuration. If the
device doesnt differentiate between running and startup configuration this will an
empty string
- startup(string) - Representation of the native startup configuration. If the
device doesnt differentiate between running and startup configuration this will an
empty string
"""
running_config = ""
startup_config = ""

if retrieve in ["all", "running"]:
running_config = self._send_command("show running-config")
if retrieve in ["all", "startup"]:
startup_config = self._send_command("show startup-config")

configs = {
"running": running_config,
"startup": startup_config,
"candidate": "",
}

if sanitized:
return sanitize_configs(configs, D6C.DELLOS6_SANITIZE_FILTERS)

return configs
12 changes: 12 additions & 0 deletions napalm_dellos6/dellos6_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Constants to be used with Dell OS6 driver."""

DELLOS6_SANITIZE_FILTERS = {
r"^(username\s+\S+\s+password)\s+(\S+)(\s+privilege\s+\d+(\s+encrypted)?)?$": r"\1 <removed>\3",
r"^(key)\s+\S+$": r"\1 <removed>",
r"^(snmp-server engineid local).*$": r"\1 <removed>",
r"^(snmp-server community)\s+\S+(\s*(ro|rw))?$": r"\1 <removed>\2",
r"^(snmp-server host \S+ traps version (1|2)) \S+(\s+(filter \S+)"
r"?(udp-port \d+)?)?$": r"\1 <removed>\3",
r"^(snmp-server host \S+ informs\s*(timeout \d+)?\s*(retries \d+)?)\s*\S+$": r"\1 <removed>",
r"^(enable\s+password)\s+(\S+)(\s+encrypted)?$": r"\1 <removed>\3",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"candidate": "",
"running": "!Current Configuration:\n!System Description \"Dell Networking N4032, 6.2.0.5, Linux 3.7.10-4134a969\"\n!System Software Version 6.2.0.5\n!Cut-through mode is configured as disabled\n!\nconfigure\nvlan 666,699,707,710,3840,4000-4002\nexit\nvlan 666\nname \"TEST\"\nexit\nvlan 699\nname \"Management1\"\nexit\nvlan 707\nname \"Site1\"\nexit\nvlan 710\nname \"Internet-Transit\"\nexit\nvlan 3840\nname \"MGMT\"\nexit\nvlan 4000\nname \"VXLAN\"\nexit\nvlan 4001\nname \"Vmotion\"\nexit\nvlan 4002\nname \"Replication\"\nexit\nsnmp-server location \"LOC\"\nhostname \"switch1\"\nslot 1/0 2 ! Dell Networking N4032\nslot 2/0 2 ! Dell Networking N4032\nsntp unicast client enable\nsntp server 192.0.2.133\nsntp server 198.51.100.133\nclock summer-time recurring USA zone \"PDT\"\nclock timezone -8 minutes 0 zone \"PST\"\nstack\nmember 1 1 ! N4032\nmember 2 1 ! N4032\nexit\ninterface out-of-band\nip address 10.238.12.11 255.255.254.0 10.238.12.1\nipv6 address fd62:9fd2:ab76:6067::12/64\nipv6 address fd62:9fd2:ab76:6066::13/64\nexit\nip vrf TEST\nexit\nip domain-name \"example.com\"\nlogging cli-command\nlogging snmp\nlogging buffered debugging\nlogging 192.0.2.246\ndescription \"syslog\"\nlevel debugging\nexit\nsystem jumbo mtu 9216\nno ip http server\ninterface vlan 1\nexit\ninterface vlan 666\nip vrf forwarding TEST\nip address 192.0.2.129 255.255.255.252\nexit\ninterface vlan 3840\nip address 10.99.39.17 255.255.255.224\nip address 192.0.2.5 255.255.255.252 secondary\nip address 192.0.2.9 255.255.255.252 secondary\nipv6 address fd62:9fd2:ab76:6069::10/64\nipv6 address fd62:9fd2:ab76:6068::11/64\nexit\nip default-gateway 192.0.2.130\nno passwords min-length\nusername \"test\" password da1809c347677d690402d93be40ceaa1 privilege 15 encrypted\naaa authentication login \"INFRA\" radius local\nradius-server host auth 192.0.2.250\nname \"radius1\"\ntimeout 3\nsource-ip 192.0.2.129\nusage login\nkey \"Eeng7sa9Cohhook2\"\nexit\nradius-server host acct 192.0.2.250\nkey \"Eeng7sa9Cohhook2\"\nname \"radius1\" \nexit\nline console\nexec-timeout 30\nexit\nline telnet\nexec-timeout 30\nexit\nline ssh\nexec-timeout 30\nexit\nip ssh server\nmanagement access-list \"MGMT\"\npermit ip-source 192.0.2.0 mask 255.255.255.0 priority 1\nexit\nmanagement access-class MGMT\n!\ninterface Te1/0/1\nchannel-group 10 mode active\ndescription \"Interface 1\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/2\nchannel-group 11 mode active\ndescription \"Interface 2\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/3\ndescription \"Interface 3\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/4 \ndescription \"Interface 4\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/5\ndescription \"Interface 5\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/6\ndescription \"Interface 6\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/7\ndescription \"Interface 7\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/8\nshutdown\ndescription \" blah \"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/9\nspanning-tree portfast\nexit\n!\ninterface Te1/0/10\nspanning-tree portfast\nexit\n!\ninterface Te1/0/11\ndescription \"Interface 11\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/12\ndescription \"Interface 12\"\nspanning-tree portfast\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te1/0/13\ndescription \"Interface 13\"\nspanning-tree portfast\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te1/0/14\ndescription \"Interface 14\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/15\ndescription \"Interface 15\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/16\ndescription \"Interface 16\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/17\ndescription \"Interface 17\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/18\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/19\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/20\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/21\nchannel-group 50 mode active\ndescription \"Interface 21\"\nspanning-tree portfast\nswitchport mode trunk\nexit\n!\ninterface Te1/0/22\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/23\ndescription \"Interface 23\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/24\ndescription \"Interface 24\"\nspanning-tree portfast\nexit\n!\ninterface Te2/0/1\nchannel-group 10 mode active\nexit\n!\ninterface Te2/0/2\nchannel-group 11 mode active\nexit\n!\ninterface Te2/0/11\ndescription \"Interface 11\"\nexit\n!\ninterface Te2/0/12\ndescription \"Interface 12\"\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te2/0/13\ndescription \"Interface 13\"\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te2/0/14\nshutdown\nexit\n!\ninterface Te2/0/15\nshutdown\nexit\n!\ninterface Te2/0/16\nshutdown\nexit\n!\ninterface Te2/0/17\nshutdown\nexit\n!\ninterface Te2/0/18\nshutdown\nexit\n!\ninterface Te2/0/19\nshutdown\nexit\n!\ninterface Te2/0/20\nshutdown\nexit\n!\ninterface Te2/0/21\nchannel-group 50 mode active\ndescription \"Interface 21\"\nswitchport mode trunk\nexit\n!\ninterface Te2/0/22\nshutdown\nexit\n!\ninterface Te2/0/23\ndescription \"Interface 23\"\nexit\n!\ninterface Te2/0/24\ndescription \"Interface 24\"\nexit\n!\ninterface port-channel 1\nswitchport mode trunk\nvpc 1\nexit\n!\ninterface port-channel 10\ndescription \"Port-channel10\"\nexit\n!\ninterface port-channel 11\ndescription \"Port-channel11\"\nexit\n!\ninterface port-channel 50\ndescription \"Port-channel50\"\nswitchport mode trunk\nswitchport trunk allowed vlan 666,699,707,710,3840,4002\nexit\nsnmp-server engineid local ef4eba9cfb702d20f5b3dc\nsnmp-server community \"public\" ro\nsnmp-server host 192.0.2.133 traps version 2 \"public\"\nsnmp-server enable traps bgp state-changes limited\nsnmp-server enable traps dvmrp\nsnmp-server enable traps pim\nsnmp-server enable traps captive-portal\nsnmp-server enable traps captive-portal client-auth-failure\nsnmp-server enable traps captive-portal client-connect\nsnmp-server enable traps captive-portal client-db-full\nsnmp-server enable traps captive-portal client-disconnect\nenable password 38d0fe97e68c78d01484299c1eba409f encrypted\nfeature vpc\nvpc domain 1\npeer-keepalive enable\npeer detection enable\nexit\nexit\n",
"startup": "!Current Configuration:\n!System Description \"Dell Networking N4032, 6.2.0.5, Linux 3.7.10-4134a969\"\n!System Software Version 6.2.0.5\n!Cut-through mode is configured as disabled\n!\nconfigure\nvlan 699,707,710,3840,4000-4002\nexit\nvlan 699\nname \"Management1\"\nexit\nvlan 707\nname \"Site1\"\nexit\nvlan 710\nname \"Internet-Transit\"\nexit\nvlan 3840\nname \"MGMT\"\nexit\nvlan 4000\nname \"VXLAN\"\nexit\nvlan 4001\nname \"Vmotion\"\nexit\nvlan 4002\nname \"Replication\"\nexit\nsnmp-server location \"LOC\"\nhostname \"switch1\"\nslot 1/0 2 ! Dell Networking N4032\nslot 2/0 2 ! Dell Networking N4032\nsntp unicast client enable\nsntp server 192.0.2.133\nsntp server 198.51.100.133\nclock summer-time recurring USA zone \"PDT\"\nclock timezone -8 minutes 0 zone \"PST\"\nstack\nmember 1 1 ! N4032\nmember 2 1 ! N4032\nexit\ninterface out-of-band\nip address 10.238.12.11 255.255.254.0 10.238.12.1\nipv6 address fd62:9fd2:ab76:6067::12/64\nipv6 address fd62:9fd2:ab76:6066::13/64\nexit\nip vrf TEST\nexit\nip domain-name \"example.com\"\nlogging cli-command\nlogging snmp\nlogging buffered debugging\nlogging 192.0.2.246\ndescription \"syslog\"\nlevel debugging\nexit\nsystem jumbo mtu 9216\nno ip http server\ninterface vlan 1\nexit\ninterface vlan 3840\nip address 10.99.39.17 255.255.255.224\nip address 192.0.2.5 255.255.255.252 secondary\nip address 192.0.2.9 255.255.255.252 secondary\nipv6 address fd62:9fd2:ab76:6069::10/64\nipv6 address fd62:9fd2:ab76:6068::11/64\nexit\nip default-gateway 192.0.2.130\nno passwords min-length\nusername \"test\" password da1809c347677d690402d93be40ceaa1 privilege 15 encrypted\naaa authentication login \"INFRA\" radius local\nradius-server host auth 192.0.2.250\nname \"radius1\"\ntimeout 3\nsource-ip 192.0.2.129\nusage login\nkey \"Eeng7sa9Cohhook2\"\nexit\nradius-server host acct 192.0.2.250\nkey \"Eeng7sa9Cohhook2\"\nname \"radius1\" \nexit\nline console\nexec-timeout 30\nexit\nline telnet\nexec-timeout 30\nexit\nline ssh\nexec-timeout 30\nexit\nip ssh server\nmanagement access-list \"MGMT\"\npermit ip-source 192.0.2.0 mask 255.255.255.0 priority 1\nexit\nmanagement access-class MGMT\n!\ninterface Te1/0/1\nchannel-group 10 mode active\ndescription \"Interface 1\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/2\nchannel-group 11 mode active\ndescription \"Interface 2\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/3\ndescription \"Interface 3\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/4 \ndescription \"Interface 4\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/5\ndescription \"Interface 5\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/6\ndescription \"Interface 6\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/7\ndescription \"Interface 7\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/8\nshutdown\ndescription \" blah \"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/9\nspanning-tree portfast\nexit\n!\ninterface Te1/0/10\nspanning-tree portfast\nexit\n!\ninterface Te1/0/11\ndescription \"Interface 11\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/12\ndescription \"Interface 12\"\nspanning-tree portfast\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te1/0/13\ndescription \"Interface 13\"\nspanning-tree portfast\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te1/0/14\ndescription \"Interface 14\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/15\ndescription \"Interface 15\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/16\ndescription \"Interface 16\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/17\ndescription \"Interface 17\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/18\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/19\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/20\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/21\nchannel-group 50 mode active\ndescription \"Interface 21\"\nspanning-tree portfast\nswitchport mode trunk\nexit\n!\ninterface Te1/0/22\nshutdown\nspanning-tree portfast\nexit\n!\ninterface Te1/0/23\ndescription \"Interface 23\"\nspanning-tree portfast\nexit\n!\ninterface Te1/0/24\ndescription \"Interface 24\"\nspanning-tree portfast\nexit\n!\ninterface Te2/0/1\nchannel-group 10 mode active\nexit\n!\ninterface Te2/0/2\nchannel-group 11 mode active\nexit\n!\ninterface Te2/0/11\ndescription \"Interface 11\"\nexit\n!\ninterface Te2/0/12\ndescription \"Interface 12\"\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te2/0/13\ndescription \"Interface 13\"\nswitchport mode trunk\nswitchport trunk allowed vlan 1,699,707,710,3840,4000-4002\nexit\n!\ninterface Te2/0/14\nshutdown\nexit\n!\ninterface Te2/0/15\nshutdown\nexit\n!\ninterface Te2/0/16\nshutdown\nexit\n!\ninterface Te2/0/17\nshutdown\nexit\n!\ninterface Te2/0/18\nshutdown\nexit\n!\ninterface Te2/0/19\nshutdown\nexit\n!\ninterface Te2/0/20\nshutdown\nexit\n!\ninterface Te2/0/21\nchannel-group 50 mode active\ndescription \"Interface 21\"\nswitchport mode trunk\nexit\n!\ninterface Te2/0/22\nshutdown\nexit\n!\ninterface Te2/0/23\ndescription \"Interface 23\"\nexit\n!\ninterface Te2/0/24\ndescription \"Interface 24\"\nexit\n!\ninterface port-channel 1\nswitchport mode trunk\nvpc 1\nexit\n!\ninterface port-channel 10\ndescription \"Port-channel10\"\nexit\n!\ninterface port-channel 11\ndescription \"Port-channel11\"\nexit\n!\ninterface port-channel 50\ndescription \"Port-channel50\"\nswitchport mode trunk\nswitchport trunk allowed vlan 699,707,710,3840,4002\nexit\nsnmp-server engineid local ef4eba9cfb702d20f5b3dc\nsnmp-server community \"public\" ro\nsnmp-server host 192.0.2.133 traps version 2 \"public\"\nsnmp-server enable traps bgp state-changes limited\nsnmp-server enable traps dvmrp\nsnmp-server enable traps pim\nsnmp-server enable traps captive-portal\nsnmp-server enable traps captive-portal client-auth-failure\nsnmp-server enable traps captive-portal client-connect\nsnmp-server enable traps captive-portal client-db-full\nsnmp-server enable traps captive-portal client-disconnect\nenable password 38d0fe97e68c78d01484299c1eba409f encrypted\nfeature vpc\nvpc domain 1\npeer-keepalive enable\npeer detection enable\nexit\nexit\n"
}
Loading

0 comments on commit b26350e

Please sign in to comment.