Skip to content

Instantly share code, notes, and snippets.

View clay584's full-sized avatar

clay584

  • Florida, USA
View GitHub Profile
@clay584
clay584 / nornit-netbox-tests.py
Created March 12, 2020 15:10
nornit-netbox-tests.py
def get_secrets(requests_mock, case, plugin, pagination, **kwargs):
if not pagination:
with open(f"{BASE_PATH}/{case}/mocked/secrets.json", "r") as f:
requests_mock.get(
"http://localhost:8080/api/secrets/secrets/?limit=0",
json=json.load(f),
headers={"Content-type": "application/json"},
)
else:
for offset in range(3):
The full traceback is:
Traceback (most recent call last):
File "/home/ccurtis/.ansible/tmp/ansible-tmp-1578728906.0116885-41951605142416/AnsiballZ_aci_config_rollback.py", line 102, in <module>
_ansiballz_main()
└ <function _ansiballz_main at 0x7fb671c6b500>
File "/home/ccurtis/.ansible/tmp/ansible-tmp-1578728906.0116885-41951605142416/AnsiballZ_aci_config_rollback.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
│ │ │ └ '{"ANSIBLE_MODULE_ARGS": {"host": "10.8.208.11", "username": "xxxxx", "password": "xxxxx", "validate_certs"...
│ │ └ '/tmp/ansible_aci_config_rollback_payload_y6sKlk'
│ └ '/tmp/ansible_aci_config_rollback_payload_y6sKlk/ansible_aci_config_rollback_payload.zip'
@clay584
clay584 / ttp_macro.py
Created October 15, 2019 20:21
ttp with macro for advanced templating
#!/usr/bin/env python
from ttp import ttp
data_to_parse = """
*Virtual Server : LO_PARTNET-AL8.COM-NGINX-EXT 68.58.239.12 All Up
+port 80 tcp ====>LO_PARTNET-AL8.COM-NGINX_HTTP State :All Up
+LO_PARTNET-AL8.COM-NGINX:80 10.44.16.220 State : Up
+port 443 tcp ====>LO_PARTNET-AL8.COM-NGINX_HTTPS State :All Up
@clay584
clay584 / test2.py
Created October 8, 2019 03:49
ttp example 2 - ASA object-groups
#!/usr/bin/env python
from ttp import ttp
import json
from pprint import pprint
from pycatj.pycatj.pycatj import process_dict, process_list
import io
def pycatj_print(data, object_name):
@clay584
clay584 / ttp_test.py
Last active October 8, 2019 03:09
ttp test of multiple host objects in ASA object-groups
#!/usr/bin/env python
from ttp import ttp
data_to_parse = """
object-group network BRAZIL_VIPS
network-object host 1.2.2.2
network-object host 2.2.2.2
network-object host 3.3.3.3
object-group network GERMANY_VIP
@clay584
clay584 / napalm.py
Last active August 24, 2019 16:59
Napalm example
#!/usr/bin/env python3
from napalm import get_network_driver
from getpass import getpass
from netmiko import NetMikoAuthenticationException
from napalm.base.exceptions import ConnectionException
from pprint import pprint
username = input('username: ')
@clay584
clay584 / sla_parser.py
Created August 16, 2019 02:02
Genie Parsergen Example
#!/usr/bin/env python3
from pyats.datastructures import AttrDict
from genie import parsergen
from genie.conf.base import Device, Testbed
from pprint import pprint
nos = "ios"
@clay584
clay584 / global_entry.py
Last active May 1, 2024 18:13
Global Entry Appointment Notifier
#!/usr/bin/env python
import requests
import time
import sys
from datetime import datetime, timedelta
from twilio.rest import Client
# Idea and details located here. I just added SMS capability
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Loopback100</name>
<config>
<name>Loopback100</name>
<type xmlns:idx="urn:ietf:params:xml:ns:yang:iana-if-type">idx:softwareLoopback</type>
<enabled>true</enabled>
<description>***REPLACE LOOPBACK 100****</description>
</config>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Loopback100</name>
<config>
<name>Loopback100</name>
<type xmlns:idx="urn:ietf:params:xml:ns:yang:iana-if-type">idx:softwareLoopback</type>
<enabled>true</enabled>
<description>***REPLACE LOOPBACK 100****</description>
</config>
</interface>