Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
@freyes
freyes / lp-attach
Created September 5, 2017 01:39
attach files to a launchpad bug from the command line
#!/usr/bin/python
#
# Usage:
# $ lp-attach 1234 foo.debdiff bar.debdiff
#
import os
import sys
from launchpadlib.launchpad import Launchpad
@freyes
freyes / juju-st
Last active August 9, 2017 20:20
juju-st
#!/usr/bin/python3
# Usage:
# $ juju status --format yaml | ./juju-st
import yaml
import select
import subprocess
import sys
from pprint import pprint
from prettytable import PrettyTable, PLAIN_COLUMNS
@freyes
freyes / rewrite.pl
Created March 22, 2017 19:56
Redirect ubuntu archive requests to another mirror when using squid as an apt proxy (or transparent proxy)
#!/usr/bin/perl
#
# url_rewrite_program /etc/squid/rewrite.pl
# add ^^^ to your squid.conf
#
$mirror = "example.com";
$| = 1;
while (<>) {
#!/bin/bash
for dname in `find . -maxdepth 1 -type d -name 'sosreport-*' `;do
for NAME in $(grep jujud ${dname}/ps | grep unit- | awk -F' ' '{print $11}' | cut -d'/' -f6); do
echo "${dname} -> ${NAME}"
ln -s ${dname} $NAME
done
done
#!/bin/python3
import colored
import sys
class bcolors:
DEBUG = 4
INFO = 26
WARNING = 11
ERROR = 1
#!/usr/bin/python
# Example output:
# 7 foo
# 32 bar
# 33 some
# 32 example
__author__ = "Felipe Reyes <[email protected]>"
import os
from collections import defaultdict
from novaclient import client
@freyes
freyes / juju-st
Last active February 17, 2017 17:43
#!/usr/bin/python3
# example output:
# $ juju st
# unit workload agent message
# neutron-gateway/0* waiting executing Incomplete relations: network-service
# neutron-api/0* active idle Unit is ready
# nova-cloud-controller/0* waiting executing Incomplete relations: neutron-api, image, database, identity, messaging
# percona-cluster/0* active idle Unit is ready
# ceph-proxy/0* active idle Ready to proxy settings
# ceph/0* active idle Unit is ready and clustered
@freyes
freyes / mem.sh
Last active February 14, 2017 14:57
print memory in megabytes
#!/bin/bash
# source: http://php.ingewikkeld.net/entry/human-readable-memory-usage-in-linux-per-process
ps -heo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
@freyes
freyes / juju-st
Created December 29, 2016 19:44
compact juju status for just the 'units' section
#!/usr/bin/python3
import json
import subprocess
from prettytable import PrettyTable, PLAIN_COLUMNS
table = PrettyTable()
table.field_names = ['unit', 'workload', 'agent', 'message']
table.set_style(PLAIN_COLUMNS)
table.align['unit'] = table.align['message'] = 'l'
#!/bin/bash
ROUTER=$1
neutron l3-agent-list-hosting-router ${ROUTER}
neutron router-update ${ROUTER} --admin-state-up=False
neutron router-update ${ROUTER} --admin-state-up=True