Skip to content

Instantly share code, notes, and snippets.

qwe
@andrewdmcleod
andrewdmcleod / plumb_interface.sh
Created September 20, 2019 11:47
add dataport to previously deployed openstack interface
#!/bin/bash
echo Adding data-port interface to netplan
OS_PORT_LIST=$(openstack port list -c "MAC Address" -c "Fixed IP Addresses")
OS_SERVER_LIST=$(openstack server list)
for IP in $(juju status neutron-gateway|grep "Machine State" -A2|tail -n2|awk '{print $3}')
do
IFS=''
@andrewdmcleod
andrewdmcleod / hashmarks.py
Last active September 20, 2019 11:49
print n hashmarks per x seconds of time elapsed via ts w epoch time
#!/usr/bin/env python3
# Takes output from "ts %s" and prints hashmark / seconds_per_hash
# e.g. bash_command | ts %s > outfile ; ./hashmarks.py outfile
import sys
rtime = 0
line_time = 0
hashstring = ""
@andrewdmcleod
andrewdmcleod / reach-fan.sh
Last active January 15, 2019 10:27
add route to juju deployed containers using fan networking
#!/bin/bash
# wait for first juju machine to get an IP addres, and then:
fannet=`juju model-config fan-config | awk -F '=' '{print $2}'`
sudo route del -net $fannet
firstmachine=`juju machines|egrep -v 'Machine|lxd'|head -n1`
sudo route add -net $fannet gw $firstmachine
@andrewdmcleod
andrewdmcleod / pipelines.py
Created August 28, 2018 09:34
jenkins pipeline aggregator viewer python script
#!/usr/bin/python3
import urllib.request, json , os, time, keyboard
class bcolors:
HEADER = '\033[95m'
IN_PROGRESS = '\033[94;5m'
SUCCESS = '\033[92m'
WARNING = '\033[93m'
FAILED = '\033[91m'
@andrewdmcleod
andrewdmcleod / start_off_slaves.groovy
Created March 9, 2018 13:28
start offline jenkins slaves
import hudson.model.*
import hudson.node_monitors.*
import hudson.slaves.*
import java.util.concurrent.*
jenkins = Hudson.instance
import javax.mail.internet.*;
import javax.mail.*
import javax.activation.*
@andrewdmcleod
andrewdmcleod / search_and_destroy.groovy
Created March 9, 2018 12:36
pipeline groovy - search and destroy jenkins job
import jenkins.model.*
import hudson.model.*
def jobName = "${JOB_NAME}"
Jenkins.instance.getAllItems(AbstractItem.class).each {
job->
job.builds.each { build->
if (build.getResult().equals(null)) {
buildname = build.toString()
@andrewdmcleod
andrewdmcleod / jst.sh
Created September 12, 2016 23:15
juju status with public ips
#!/bin/bash
set -f; IFS=$'\n'
juju status --format=tabular|sed -n '1,/Machines/ p'
#juju status --format=tabular|sed '/\[Machines\]/q'
echo .
echo 'ID STATE VERSION PRIVATE-IP PUBLIC-IP INS-ID SERIES HARDWARE'
machines=$(juju status --format=tabular|grep arch)
for a in $machines
@andrewdmcleod
andrewdmcleod / make_generic.py
Created August 9, 2016 13:04
Modify a juju bundle - change charms to 'ubuntu' or other as specified
#!/usr/bin/env python
import yaml
import argparse
import sys
parser = argparse.ArgumentParser(description="Process bundle.yaml and output without relations or options.")
parser.add_argument('-i', '--input', help="name of input yaml")
parser.add_argument('-o', '--output', help="name of output yaml")
parser.add_argument('-c', '--charm', help="charm url to use as replacement")
@andrewdmcleod
andrewdmcleod / bashrc
Last active June 7, 2016 10:04
juju aliases
jgs() { juju run --unit $1 "charms.reactive --format=yaml get_states"; }
jdo() { juju action fetch --wait 0 $(juju action do $1 $2 | awk '{print $5}'); }
jupdate() { juju run --unit $1 'hooks/update-status'; }