Skip to content

Instantly share code, notes, and snippets.

@ubaumann
ubaumann / dump_infrahub_schema.py
Created October 27, 2025 22:42
infrahub run script to dump schema
# Script to pull schema information from Infrahub and serialize it to YAML
# infrahubctl run <script>
# Dependencies: infrahub-sdk, pyyaml
# alpha version, need testing
import logging
import yaml
from infrahub_sdk import InfrahubClient, Config
from infrahub_sdk.schema import (
@ubaumann
ubaumann / nornir_config_schema.json
Last active January 31, 2022 18:07
Nornir Configuration JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "schema/schemas/config.json",
"type": "object",
"$ref": "#/definitions/Configuration",
"definitions": {
"Configuration": {
"type": "object",
"additionalProperties": false,
"properties": {
import csv
def dscp_class(dec):
if dec == 46:
return "ef"
major_class = dec >> 3
drop_preference = dec >> 1 & 3
if drop_preference == 0:
return f"cs{major_class}"