Skip to content

Instantly share code, notes, and snippets.

$ sudo maas-region dbshell
maasdb=# SELECT r.gateway_ip, metric, source.cidr source, dest.cidr destination
FROM maasserver_staticroute r
JOIN maasserver_subnet source ON source.id = r.source_id
JOIN maasserver_subnet dest on dest.id = r.destination_id;
ubuntu@maas:~$ curl tftp://localhost/pxelinux.cfg/01-52-54-00-74-1e-ce
DEFAULT execute
LABEL execute
SAY Booting under MAAS direction...
SAY nomodeset iscsi_target_name=iqn.2004-05.com.ubuntu:maas:ephemeral-ubuntu-amd64-hwe-x-xenial-daily iscsi_target_ip=127.0.0.1 iscsi_target_port=3260 iscsi_initiator=pxe1 ip=::::pxe1:BOOTIF ip6=off ro root=/dev/disk/by-path/ip-127.0.0.1:3260-iscsi-iqn.2004-05.com.ubuntu:maas:ephemeral-ubuntu-amd64-hwe-x-xenial-daily-lun-1 overlayroot=tmpfs cc:{'datasource_list': ['MAAS']}end_cc cloud-config-url=http://172.16.99.2:5240/MAAS/metadata/latest/by-id/nce47f/?op=get_preseed log_host=172.16.99.2 log_port=514
KERNEL ubuntu/amd64/hwe-x/xenial/daily/boot-kernel
INITRD ubuntu/amd64/hwe-x/xenial/daily/boot-initrd
APPEND nomodeset iscsi_target_name=iqn.2004-05.com.ubuntu:maas:ephemeral-ubuntu-amd64-hwe-x-xenial-daily iscsi_target_ip=127.0.0.1 iscsi_target_port=3260 iscsi_initiator=pxe1 ip=::::pxe1:BOOTIF ip6=off ro root=/dev/disk/by-path/ip-127.0.0.1:3260-iscsi-iqn.2004-05.com
# This is an example of how to do an OAuth1 request manually, such as when a deploying MAAS node hits the metadata server.
# Grab the TFTP config for the deploying/commissioning machine.
# curl tftp://localhost/pxelinux.cfg/01-52-54-00-0a-25-ac
APPEND nomodeset ... cloud-config-url=http://172.16.99.2:5240/MAAS/metadata/latest/by-id/nrwbgy/?op=get_preseed ...
# Grab the cloud-config for the machine.
# curl http://172.16.99.2:5240/MAAS/metadata/latest/by-id/nrwbgy/?op=get_preseed
...
#!/usr/bin/env python
import socket
import time
servers = [
["Local Network - Survival Peaceful", 25565],
["Local Network - Survival Normal", 25566],
["Local Network - Survival Hard with Diamonds", 25567],
]
#!/usr/bin/env python
import socket
import time
import sys
from scapy.all import *
conf.verb = 0
servers = [
#!/usr/bin/env python
import re
import sys
import select
import socket
import struct
import time
port = 4445
@mpontillo
mpontillo / find_and_sort_symlinks.sh
Last active January 5, 2017 22:27
Shell snippet to list symlinks and then sort by link destination. (Useful for looking at /dev/disk and other things.)
@mpontillo
mpontillo / get_block_device_details.sh
Last active January 26, 2017 04:59
Print detailed information about each block device. (Tested on Ubuntu 16.04.)
#!/bin/bash
# Note: excluding ramdisks, floppy drives, and loopback devices.
lsblk --exclude 1,2,7 -d -P
echo ""
for dev in $(lsblk -n --exclude 1,2,7 --output KNAME); do
echo "$dev:"
udevadm info -q all -n $dev
echo ""
echo " size64: $(sudo -n blockdev --getsize64 /dev/$dev 2> /dev/null || echo unknown)"
@mpontillo
mpontillo / show_tput.sh
Created January 10, 2017 02:17
Use `tput` to show some different combinations of colors and settings.
#!/bin/bash
function normal {
tput sgr0
}
normal="$(normal)"
function example {
printf "%s" "${normal}"
@mpontillo
mpontillo / pysnmp_example.py
Last active March 28, 2017 00:35
PySNMP example which scans a CIDR and tries to read the system MIB for each host.
#!/usr/bin/env python3
"""
This file contains example code from the PySNMP project, which has been
heavily modified to only walk specified MIBs.
Examples in the comments include information on how to connect to a device
using SNMPv3, with or without privacy (and an authentication digest).
"""
import sys
from functools import partial