Skip to content

Instantly share code, notes, and snippets.

@vernhart
vernhart / microk8s-auto-cluster
Created July 19, 2023 15:05
Auto cluster microk8s nodes using avahi advertisements
#!/bin/bash
servicefile=/var/snap/avahi/common/etc/avahi/services/microk8s.service
tokenfile=/var/snap/microk8s/current/credentials/cluster-tokens.txt
interval=5
while sleep $interval; do
if [ -z "$(avahi.browse -rtp --ignore-local _microk8s-cluster._tcp)" ]; then
interval=60
# if the service doesn't exist, we'll publish it
# this token could be pre-shared and perhaps modified with the current time
NS="qrouter-$(openstack router show ubuntu-router -f value -c id)"
juju run --unit neutron-gateway/leader "
# this creates two interfaces connected by a virtual cable
ip link add name vethhost0 type veth peer name vethns0
# and the put the second interface within the namespace
ip link set vethns0 netns $NS
ip addr add 172.30.30.1/30 dev vethhost0
ip -n $NS addr add 172.30.30.2/30 dev vethns0
ip link set vethhost0 up
ip -n $NS link set vethns0 up
@vernhart
vernhart / magpie-parse.sh
Created June 2, 2020 22:24
Parse the generated output from the fce magpie layer.
#!/bin/bash
# The magpie layer of the fce produces a magpie.json file.
# Unfortunately, the file contains the unit numbers, not the hostnames.
# And since the model is destroyed at the end, we have to parse logs
# to determine what machines had what results.
#- name: magpie
# type: magpie_maas
# parent: juju_maas_controller

Keybase proof

I hereby claim:

  • I am vernhart on github.
  • I am vernhart (https://keybase.io/vernhart) on keybase.
  • I have a public key ASCvUuVrHbw-yJ5kiRPmNwc7fNMobJDZT9bGxDHuyaZymAo

To claim this, I am signing this object:

@vernhart
vernhart / rmvpc.py
Last active November 16, 2022 07:39
Deleting an AWS VPC with python's boto3
#!/usr/bin/env python
"""I was trying to programatically remove a Virtual Private Cloud (VPC) in
AWS and the error message was not helpful:
botocore.exceptions.ClientError: An error occurred (DependencyViolation)
when calling the DeleteVpc operation: The vpc 'vpc-c12029b9' has
dependencies and cannot be deleted.
Searching for a quick solution was not fruitful but I was able to glean some
knowledge from Neil Swinton's gist: