Skip to content

Instantly share code, notes, and snippets.

View renatoalmeidaoliveira's full-sized avatar

Renato Almeida de Oliveira renatoalmeidaoliveira

View GitHub Profile
digraph model_graph {
// Dotfile by Django-Extensions graph_models
// Created: 2023-08-19 16:38
// Cli Options: -a -I VirtualMachine,VMInterface,Tenant,IPAddress,ContentType --rankdir LR
fontname = "Roboto"
fontsize = 8
splines = true
rankdir = "LR"
@renatoalmeidaoliveira
renatoalmeidaoliveira / case_sensitive_report.py
Last active December 20, 2022 17:37
Device case sensitive report
from dcim.models import Device, DeviceType, Site
from extras.reports import Report
class DeviceReport(Report):
description = "Check device case insensitive name"
@property
@renatoalmeidaoliveira
renatoalmeidaoliveira / netbox_async_get.py
Last active December 18, 2022 14:06
Netbox GET aiohttp sample
NETBOX_TOKEN = "<token>"
NETBOX_URL = "https://netbox.sample.com/api/"
async def netbox_get(endpoint, params={}):
api_token = NETBOX_TOKEN
api_url = NETBOX_URL
url = f"{api_url}{endpoint}"
headers = {
"accept": "application/json",
"Authorization": f"Token {api_token}",
}
@renatoalmeidaoliveira
renatoalmeidaoliveira / conf.ini
Created November 11, 2022 19:02
Netbox Webhoocks integration with exaBGP
process http-api {
run /home/renato/rtbh/venv/bin/python /home/renato/rtbh/http_api.py;
encoder text;
}
template {
neighbor AS_65000 {
router-id 192.168.194.132;
local-as 65000;
local-address 192.168.194.132;
peer-as 65000;
mkdir .ssh
chmod 700 .ssh/
touch .ssh/authorized_keys
chmod 644 .ssh/authorized_keys
@renatoalmeidaoliveira
renatoalmeidaoliveira / generate.py
Created October 22, 2021 22:59
ContainerLab random labs
#! /usr/bin/env python
import networkx as nx
from jinja2 import Environment, FileSystemLoader
nodes = 10
G = nx.erdos_renyi_graph(nodes, 0.6)
links = []
nodes_links = {}
@renatoalmeidaoliveira
renatoalmeidaoliveira / genie_scrapli.py
Created September 28, 2021 23:04
Using Scrapli as PyATS Connection Plugin
from pyats.connections import BaseConnection
from pyats.utils.secret_strings import to_plaintext
from scrapli import Scrapli as Scrapli_connector
class Scrapli(BaseConnection):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._is_connected = False
@renatoalmeidaoliveira
renatoalmeidaoliveira / connected_interfaces.py
Created September 17, 2021 02:55
A simple Netbox report that checks if all the enabled interfaces are connected. Creating a new section for each site.
from extras.reports import Report
from dcim.models import Device
from dcim.models import Site
class ConnectedInterfaces(Report):
description = "Check if all enabled interface are connected"
def __init__(self, *args, **kwargs):
for site in Site.objects.all():
@renatoalmeidaoliveira
renatoalmeidaoliveira / generate-ssh-key.sh
Created March 28, 2021 05:24 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa

Keybase proof

I hereby claim:

  • I am renatoalmeidaoliveira on github.
  • I am renatooliveira (https://keybase.io/renatooliveira) on keybase.
  • I have a public key ASAl-M2Ue8r949QcaFG-Nf76eySB9vablQ4gAQzwk2Sb0Ao

To claim this, I am signing this object: