Skip to content

Instantly share code, notes, and snippets.

View niedbalski's full-sized avatar
👋
Be humble. Stay focused.

Jorge Niedbalski niedbalski

👋
Be humble. Stay focused.
View GitHub Profile
@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
}
juju run --application rabbitmq-server 'relation-get -r `relation-ids cluster` - rabbitmq-server/1'
juju run --service nova-compute 'relation-get -r `relation-ids amqp` - rabbitmq-server/1'
erl -sname tester -setcookie $(cat /var/lib/rabbitmq/.erlang.cookie) -remsh rabbit@$(hostname)
io:format("~p", [dict:find(rabbit, dict:from_list(rabbit:environment()))]).
export MYSQLPWD=$(juju run --unit percona-cluster/0 leader-get | grep "mysql.passwd" | cut -d' ' -f2 | tail -n 1)
juju ssh percona-cluster/0 sudo mysql -p$MYSQLPWD -e 'show\ databases;'
@niedbalski
niedbalski / corosync tweaks
Created March 30, 2017 19:23
corosync variables
# For non-systemd based systems, prefix export to each enabled line
#==#==# Variables that control logging
# Enable debug logging globally or per-subsystem
# Multiple subsystems may me listed separated by commas
# eg. PCMK_debug=crmd,pengine
PCMK_debug=yes
# Send INFO (and higher) messages to the named log file
@niedbalski
niedbalski / mongodump-juju2.sh
Last active January 10, 2017 19:13
dump a mongo database of juju 2
$ juju ssh ubuntu@$(juju status -m controller | grep -E '(started)'| awk '{print $3}')
$ sudo /usr/lib/juju/mongo3.2/bin/mongodump -h 127.0.0.1 --port 37017 --ssl -u admin -p $(sudo grep oldpassword
/var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2) --authenticationDatabase admin --db juju