Skip to content

Instantly share code, notes, and snippets.

View jathanism's full-sized avatar
🍕
See below.

Jathan McCollum jathanism

🍕
See below.
View GitHub Profile
@jathanism
jathanism / README.md
Created October 10, 2023 16:43 — forked from koshatul/README.md
use Apple Keychain to store GPG Passphrases

gpg-agent setup

Need to setup gpg-agent first, on OSX I use keychain (it also does ssh-agent)

$ brew info keychain
keychain: stable 2.8.5
User-friendly front-end to ssh-agent(1)
https://www.funtoo.org/Keychain
/usr/local/Cellar/keychain/2.8.5 (7 files, 108.5KB) *
@jathanism
jathanism / merge_dicts.py
Created September 20, 2022 19:47 — forked from rmax/merge_dicts.py
using itertools's chain and groupby to merge a list of dictionaries
def merge_dicts(dict_list):
"""Merge all values from dict list into a single dict
>>> d1 = {'a': 1, 'b': 2}
>>> d2 = {'a': 2, 'b': 3}
>>> merge_dicts([d1, d2])
{'a': [1, 2], 'b': [2, 3]}
"""
kviter = chain.from_iterable(d.iteritems() for d in dict_list)
@jathanism
jathanism / schema.py
Created August 23, 2022 18:33
Trying to extend OpenAPI Token Authentication via drf-spectacular for Nautobot. Hint: It doesn't work.
# This was added to schema.py so that it automatically gets applied when the schema is generated.
from drf_spectacular.extensions import OpenApiAuthenticationExtension, OpenApiSerializerFieldExtension
from drf_spectacular.plumbing import build_bearer_security_scheme_object
class TokenScheme(OpenApiAuthenticationExtension):
target_class = "rest_framework.authentication.TokenAuthentication"
name = "tokenAuth"
match_subclasses = True
@jathanism
jathanism / dag.md
Created August 16, 2022 22:38
Notes on using DAGs with Python.
@jathanism
jathanism / testjob.py
Created April 13, 2022 21:20 — forked from wvandeun/testjob.py
Nautobot test job
from nautobot.dcim.models import Device
from nautobot.dcim.models import Interface
from nautobot.dcim.choices import InterfaceTypeChoices
from nautobot.ipam.models import VLAN
from nautobot.extras.jobs import Job
class TestJob(Job):
class Meta:
description = "Some job jo!"
@jathanism
jathanism / nautobot-aws.md
Created November 17, 2021 22:18
Nautobot on AWS. Credit to Mathias Wegner on Network to Code's Slack community!

Nautobot on AWS

This is a brief summary of setting up Nautobot on AWS. I used Nautobot 1.1.3, but it should not vary too much when using different versions. It assumes some familiarity with Nautobot and AWS. Pretty much all of the AWS cli commands are the bare minimum to stand up some version of this and only show creating one resource if multiple identical resources are needed, you should add tags and consider your needs around sizing, redundancy, etc. The end result is a basic Nautobot deployment. It is not doing any scaling, just one http server and one celery worker.

Starting infrastructure and configurations

  • a VPC containing 2 private and 2 public subnets, with each pair of subnets in two different AZs
  • routes configured back to your on premise network from the VPC
  • an ec2 bastion host with an interface on the private subnet for local access to EFS and RDS
  • a nautobot_config.py file that has been updated to meet your needs
  • a nautobot.env file that has been updated to meet your
@jathanism
jathanism / select_option_for_select2.py
Created October 22, 2021 17:49 — forked from Alireza2n/select_option_for_select2.py
a function to interact with select2 element using Selenium and Python (inspired by https://stackoverflow.com/a/17757761/8504344 and tested on firefox)
def select_option_for_select2(driver, id, text=None):
element = driver.find_element(By.XPATH, '//*[@id="{}"]/following-sibling::*[1]'.format(id))
element.click()
if text:
element = driver.find_element(By.CSS_SELECTOR, "input[type=search]")
element.send_keys(text)
try:
element.send_keys(Keys.ENTER)
From 19e3203ea649a2668629eb66088f004a8747248c Mon Sep 17 00:00:00 2001
From: jathanism <jathan@gmail.com>
Date: Tue, 13 Apr 2021 15:34:02 -0700
Subject: [PATCH] Patch for IPv6 ending in non-integer (a-f)
---
nautobot/ipam/querysets.py | 2 +-
nautobot/ipam/tests/test_querysets.py | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
From 3e282e34a0387ea80ff2500c936d107c369c08ba Mon Sep 17 00:00:00 2001
From: jathanism <jathan@gmail.com>
Date: Tue, 13 Apr 2021 13:19:27 -0700
Subject: [PATCH] Extend `IPAddress.objects.string_search` to support IPv6
---
nautobot/ipam/querysets.py | 83 +++++++++++++++++++++++----
nautobot/ipam/tests/test_filters.py | 10 ++++
nautobot/ipam/tests/test_querysets.py | 44 ++++++++++++++
3 files changed, 126 insertions(+), 11 deletions(-)
import re
import netaddr
RE_COLON = re.compile(".*::$")
def parse_network_as_string(search):
"""