Skip to content

Instantly share code, notes, and snippets.

@mwadman
mwadman / azure_image_convert.sh
Last active January 25, 2024 08:18
Converts a Virtual Machine image into an Azure compliant VHD
#!/usr/bin/env bash
# Script partly from https://learn.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic#resizing-vhds
# Instantiate variables
input_file=$1 # Gets full filename (e.g. "CentOS-7-x86_64-GenericCloud-2009.qcow2")
input_filename="${input_file%.*}" # Gets just the name, without extension (e.g. "CentOS-7-x86_64-GenericCloud-2009")
input_format=$(qemu-img info --output json $1 | jq -r '.format') # Gets format of image, without relying on extension to be correct (e.g. "qcow2")
# Convert image to raw if input image isn't, and a raw version doesn't exist (e.g. hasn't already been created).
if [[ $input_format != "raw" ]] && [[ ! -f "${input_filename}.raw" ]]; then
set interfaces pt-1/0/0 description "VDSL Interface"
set interfaces pt-1/0/0 vlan-tagging
set interfaces pt-1/0/0 vdsl-options vdsl-profile auto
set interfaces pt-1/0/0 unit 0 encapsulation ppp-over-ether
set interfaces pt-1/0/0 unit 0 vlan-id 10
set interfaces pp0 unit 1 description "PPPoE for VDSL"
set interfaces pp0 unit 1 ppp-options pap local-name "$username"
set interfaces pp0 unit 1 ppp-options pap local-password "$password"
set interfaces pp0 unit 1 ppp-options pap passive
set interfaces pp0 unit 1 pppoe-options underlying-interface pt-1/0/0.0
set interfaces ge-0/0/0 description "UFB Physical Uplink"
set interfaces ge-0/0/0 vlan-tagging
set interfaces ge-0/0/0 unit 0 description "UFB Logical Uplink"
set interfaces ge-0/0/0 unit 0 encapsulation ppp-over-ether
set interfaces ge-0/0/0 unit 0 vlan-id 10
set interfaces pp0 unit 1 description "PPPoE for UFB"
set interfaces pp0 unit 1 ppp-options pap local-name "$username"
set interfaces pp0 unit 1 ppp-options pap local-password "$password"
set interfaces pp0 unit 1 ppp-options pap passive
set interfaces pp0 unit 1 pppoe-options underlying-interface ge-0/0/0.0
#!/usr/bin/env python3
from ncclient import manager
from ncclient.xml_ import *
import docker
# Functions
def get_docker_ip(container_name):
client = docker.APIClient(base_url='unix://var/run/docker.sock')
#!/usr/bin/env python3
import docker
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
from jnpr.junos.exception import *
from lxml import etree
# Functions
@mwadman
mwadman / cheatsheet.tex
Last active December 8, 2019 04:40
A Tex file with multiple examples
\documentclass[]{article}
\usepackage[utf8]{inputenc}
%%%%%%%%%%%%
% Packages %
%%%%%%%%%%%%
% Page Geometry (Size, Margins)
\usepackage{geometry}
\geometry{