Skip to content

Instantly share code, notes, and snippets.

View niedbalski's full-sized avatar
Be humble and stay focused

Jorge Niedbalski niedbalski

Be humble and stay focused
View GitHub Profile
@niedbalski
niedbalski / mr-provisioner-static-ips.py
Created December 7, 2017 20:07
mr-provisioner find static ips
#!/usr/bin/env python3
"""Show allocated static ips on mr-provisioner.
Usage of this script:
{0} provisioner-url token"""
from urllib.parse import urljoin
import requests
import sys
@niedbalski
niedbalski / set-relation-ids.sh
Created October 27, 2017 10:06
relation-ids-set.sh
#!/bin/bash
# ./set-reldata.sh percona-cluster/0 cluster foo=bar bar=foo
set -ex
for id in $(juju run --unit $1 "relation-ids $2"); do
for unit in $(juju run --unit $1 "relation-list $id"); do
juju run --unit $unit "relation-set -r $id ${@:3}"
done
done
@niedbalski
niedbalski / strace-radosgw.sh
Created September 27, 2017 16:04
strace-radosgw.sh
#!/bin/bash
set -e
trace_dir=${2:-trace}
if [ ! -e ${trace_dir} ]; then
mkdir ${trace_dir}
fi
@niedbalski
niedbalski / strace-hook.sh
Last active September 14, 2017 20:29
strace-hook.sh
#!/bin/bash
# ./strace-hook.sh update-status
# this command straces all the processes and subprocesses spawned
# by a particular juju hook when is run.
set -e
hook=${1:-update-status}
regex=".*${hook}.*"
trace_dir=${2:-trace}
@niedbalski
niedbalski / maas_allocated_ip_addresses.sql
Created July 17, 2017 21:46 — forked from mpontillo/maas_allocated_ip_addresses.sql
List IP addresses allocated in MAAS.
SELECT
sip.ip,
CASE
WHEN sip.alloc_type = 0 THEN 'AUTO'
WHEN sip.alloc_type = 1 THEN 'STICKY'
WHEN sip.alloc_type = 4 THEN 'USER_RESERVED'
WHEN sip.alloc_type = 5 THEN 'DHCP'
WHEN sip.alloc_type = 6 THEN 'DISCOVERED'
ELSE CAST(sip.alloc_type as CHAR)
END "alloc_type",
size=$(stat -Lc%s centos.iso)
virsh vol-create-as default centos $size --format raw
virsh vol-upload --pool default centos centos.iso
@niedbalski
niedbalski / recover-rabbit.sh
Created July 5, 2017 16:04
Recover a rabbitmq cluster after partitioning
Some notes from engineering.
1) Identify the partition
Mnesia('rabbit@juju-machine-30-lxd-11'): ** ERROR ** mnesia_event got {inconsistent_database, running_partitioned_network, 'rabbit@juju-machine-29-lxd-9'}
$ sudo rabbitmqctl cluster_status
2) Pick the most reliable node as the master.
@niedbalski
niedbalski / charm-is-latest.sh
Created June 13, 2017 20:04
Check if the latest published artifact on charmstore matches with current github tip for a given branch
function charmislatest() {
if [ ! ${#@} -ge 2 ]; then
echo -e "Please provide a charm name and a branch" && return;
fi
q=$(curl -s https://api.github.com/repos/openstack/charm-$1/commits/stable/$2 | python -c "import sys, json; q=json.load(sys.stdin); print q['sha']")
head=$(curl -s https://api.jujucharms.com/charmstore/v5/$1/meta/extra-info | python -c "import sys, json; q=json.load(sys.stdin)['vcs-revisions'][-1]; print q['commit'];")
if [ "$head" == "$q" ]; then
echo "OK - $1 (Charmstore: $head == Github($2): $q)"
else
echo "Not OK - Charm is not latest: $q != $head"
/var/log/juju/*.log {
daily
minsize 5M
maxsize 50M
copytruncate
rotate 7
missingok
compress
delaycompress
}