Skip to content

Instantly share code, notes, and snippets.

View JohnPreston's full-sized avatar
🏠
Working on AWS' cloud

John Preston JohnPreston

🏠
Working on AWS' cloud
View GitHub Profile
@JohnPreston
JohnPreston / GIT RPMS
Last active December 29, 2015 09:19
Get all GIT rpms in a given version from pkgs.repoforge.org
for rpm in `curl http://pkgs.repoforge.org/git/ | grep CentOS | grep '1.7.11.3' | grep el6 | grep x86_64 | cut -d ' ' -f 8 | sed 's/href="//g' | sed 's/".*//g' ` ; do wget http://pkgs.repoforge.org/git/$rpm ;
done
@JohnPreston
JohnPreston / setup_py2.7_centos.sh
Last active August 29, 2015 13:56
Setup Python 2.7 on CentOS
#
# Setup python 2.7 in addition to 2.6.6 on CentOS 6
#
# prerequisites repos
sudo yum groupinstall "Development tools" -y
sudo yum install wget zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel mysql-devel -y
#python sources
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
@JohnPreston
JohnPreston / dump_db.sh
Last active August 29, 2015 13:56
Dump Eucalyptus DBs
#!/usr/bin/env bash
# gets the list of DBs
$DBS = psql -h /var/lib/eucalyptus/db/data -p 8777 -l | awk '{print $1}' | grep euca
#creates the dumps
for db in $DBS ; do pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root $db > $db-`date +%Y-%m-%d_%Hh%M`.sql ; done
@JohnPreston
JohnPreston / get packages given version
Last active August 29, 2015 14:04
Eucalyptus packages
for i in `curl $URL | grep $VERSION | sed 's/rpm.*/rpm/g' | cut -d = -f 5 | sed 's/\"//g'` ; do echo $i && curl -O $URL/$i ; done
@JohnPreston
JohnPreston / network.json
Created August 15, 2014 12:25
Eucalyptus network JSON config file
{
"InstanceDnsDomain": "eucalyptus.internal",
"InstanceDnsServers": [
"10.1.1.254"
],
"PublicIps": [
"10.104.6.1-10.104.6.62"
],
"Subnets": [],
"Clusters": [
@JohnPreston
JohnPreston / cidr_regexps
Created August 17, 2014 00:20
CIDR regexps
prefix => (?:\d{1,2}|)$
IP _> \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
68 pg_dumpall --oids -c -h/var/lib/eucalyptus/db/data -p8777 -Uroot -f~/eucalyptus_pg_dumpall-backup.sql
69 ll
70 pg_dumpall --oids -c -h/var/lib/eucalyptus/db/data -p8777 -Uroot -f ~/eucalyptus_pg_dumpall-backup.sql
71 tar -czvf ~/eucalyptus-keydir.tgz /var/lib/eucalyptus/keys
72 /etc/init.d/eucalyptus-cloud stop
73 ll
74 rm -rf /var/lib/eucalyptus/db
75 euca_conf --initialize
76 su eucalyptus -c "/usr/pgsql-9.1/bin/pg_ctl start -w -s -D/var/lib/eucalyptus/db/data -o '-h0.0.0.0/0 -p8777 -i'"
77 psql -U root -d postgres -p 8777 -h /var/lib/eucalyptus/db/data -f ~/eucalyptus_pg_dumpall-backup.sql
@JohnPreston
JohnPreston / euca-MSAD.lic
Last active August 29, 2015 14:05
Euca - AD synchronisation template
{
"ldap-service":{
"server-url":"ldap://192.168.91.43:389",
"auth-method":"simple",
"user-auth-method":"simple",
"auth-principal":"cn=rodc,cn=Users,dc=eucalyptus,dc=lan",
"auth-credentials":"{{ encrypted password }}",
"use-ssl":"false",
@JohnPreston
JohnPreston / change_instance_type.sh
Created August 31, 2014 12:18
Update Instance Type
#!/usr/bin/env bash
#
# This must be used with care and only knowing what you are doing.
# Eucalyptus cant be taken reponsible for bad usage of this script
#
NEWTYPE=$1
INSTANCE=$2
@JohnPreston
JohnPreston / Debbuging
Last active August 29, 2015 14:06
EDGE Debugging
# Run instances in AZs
for i in 1 2 3 4 ; do for j in 1 2 3 4 ; do euca-run-instances -z az_$i -n 60 -k key emi-ID -d Hello ;done done ;date
# Gets connected to every instances using the public address
for i in `euca-describe-instances verbose | grep INST | awk '{print $13}'`; do ssh -i /root/.euca/admintest.pem -o UserKnownHostsFile=/dev/null $i -o StrictHostKeyChecking=no curl -s 169.254.169.254/latest/user-data 2>/dev/null; echo ; done | wc -l
# gets information from NC about the IP and instances state
ansible nc -m shell -a 'echo -n "N*eucanted processes:"; ps faux | grep eucanetd| grep \/\/ | wc -l ; echo -n "PUB IPs :" ; ip addr sh eth0 | grep inet | grep -v inet6| wc -l; echo -n "N* VNET : "; ifconfig | grep vnet | wc -l ; echo -n "InstanceRunning :"; virsh list | grep i- | wc -l' > ips_instances_proc_`date +%Y-%m-%d_%H-%M`.log
# makes sure that the meta-data rule is set on NCs