This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2.environment import Environment | |
from jinja2 import FileSystemLoader, StrictUndefined | |
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipmath | |
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipaddr | |
env = Environment(undefined=StrictUndefined) | |
env.loader = FileSystemLoader(['.', './templates/']) | |
env.filters["ipmath"] = ipmath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from snmp_helper import snmp_extract, snmp_get_oid_v3 | |
last_changed = snmp_extract(snmp_get_oid_v3(snmp_device, | |
snmp_user, oid=oid, | |
auth_proto=auth_protocol, | |
encrypt_proto=encrypt_protocol, | |
display_errors=False)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseTestGetters(object): | |
"""Base class for testing drivers.""" | |
def test_method_signatures(self): | |
"""Test that all methods have the same signature.""" | |
# Method signatures that are migrating from old to new state (temporary state) | |
TRANSITION_SIGNATURES = [ | |
'commit_config', | |
'commit_confirm', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks: | |
- ios_facts: | |
provider: "{{ creds }}" | |
- ios_config: | |
provider: "{{ creds }}" | |
lines: | |
- ip helper-address 1.1.1.1 | |
parents: interface {{ item }} | |
with_items: "{{ dhcp_interfaces }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new_output: | |
changed: false | |
msg: "All items completed" | |
results: | |
- item: Vlan99 | |
stdout: ["Building configuration...\n\nCurrent configuration : 66 bytes\n!\ninterface Vlan99\n no ip address\n ip helper-address 1.1.1.1\nend\n",] | |
warnings: [] | |
- item: Vlan1 | |
stdout: ["Building configuration...\n\nCurrent configuration : 66 bytes\n!\ninterface Vlan99\n no ip address\n ip helper-address 1.1.1.1\nend\n",] | |
warnings: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{u'Ethernet3/1/1': {u'physical_channels': {u'channel': [{u'index': 0, | |
u'state': {u'input_power': {u'avg': 0.0, | |
u'instant': -1.8025870272698974, | |
u'max': 0.0, | |
u'min': 0.0}, | |
u'laser_bias_current': {u'avg': 0.0, | |
u'instant': 6.306, | |
u'max': 0.0, | |
u'min': 0.0}, | |
u'output_power': {u'avg': 0.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import jsonrpclib | |
import ssl | |
ssl._create_default_https_context = ssl._create_unverified_context | |
class AristaSwitch(object): | |
def __init__(self, switch, username, password): | |
self.switch = switch | |
self.username = username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import threading | |
from Queue import Queue | |
from getpass import getpass | |
from netmiko import ConnectHandler | |
from datetime import datetime | |
USER = 'pyclass' | |
PASSWORD = getpass() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: NAPALM vlan configuration | |
hosts: pynet-sw1 | |
gather_facts: False | |
tasks: | |
- napalm_install_config: | |
hostname: "{{ eapi_hostname }}" | |
username: "{{ eapi_username }}" | |
password: "{{ eapi_password }}" | |
dev_os: eos | |
config_file: pynet-sw1-merge.cfg |
NewerOlder