Created
December 6, 2012 04:03
-
-
Save jameskyle/4221689 to your computer and use it in GitHub Desktop.
tiny setup script for openstack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMAGE="7e572d23-6129-4f63-8454-8ab4995dd0e4" | |
KEY_NAME=my_key | |
#NOVARC=~/.cloud/blackflag-oauth-dev-dfw2-novarc | |
#source $NOVARC | |
NOVA=nova | |
M1_TINY=1 # 512MB ram | |
M1_SMALL=2 # 2GB ram | |
M1_MEDIUM=3 # 4GB ram | |
M1_LARGE=4 # 8GB ram | |
M1_XLARGE=5 # 16GB ram | |
function create_instance() | |
{ | |
$NOVA boot --image $IMAGE \ | |
--key_name $KEY_NAME \ | |
--flavor $1 \ | |
--security_groups default,$2 \ | |
$3 | |
sleep 10 | |
$NOVA add-floating-ip $3 $4 | |
} | |
function create_secgroups() | |
{ | |
$NOVA secgroup-create https "Opens https port" | |
$NOVA secgroup-create http "Opens http port" | |
$NOVA secgroup-create ssh "Opens port 22" | |
$NOVA secgroup-create pgsql "Opens port 5432 for postgresql" | |
$NOVA secgroup-add-rule ssh tcp 22 22 0.0.0.0/0 | |
$NOVA secgroup-add-rule https tcp 443 443 0.0.0.0/0 | |
$NOVA secgroup-add-rule http tcp 80 80 0.0.0.0/0 | |
$NOVA secgroup-add-rule pgsql tcp 5432 5432 0.0.0.0/0 | |
$NOVA secgroup-add-rule default icmp -1 -1 0.0.0.0/0 | |
} | |
function delete_secgroups() | |
{ | |
$NOVA secgroup-delete https | |
$NOVA secgroup-delete http | |
$NOVA secgroup-delete ssh | |
$NOVA secgroup-delete pgsql | |
} | |
function delete_instance() { | |
$NOVA delete $1 | |
} | |
function main() { | |
case $1 in | |
setup ) | |
create_secgroups | |
create_instance $M1_SMALL default,ssh jump 108.92.45.10 | |
create_instance $M1_LARGE default,http,https jenkins 108.92.45.11 | |
;; | |
teardown ) | |
delete_instance jump | |
delete_instance jenkins | |
delete_secgroups | |
;; | |
esac | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment