Skip to content

Commit c4ff8fb

Browse files
committed
Fixing snafu from earlier.
1 parent 9b8a848 commit c4ff8fb

File tree

9 files changed

+227
-131
lines changed

9 files changed

+227
-131
lines changed
File renamed without changes.

aws/aws_boto_interface.py

Lines changed: 0 additions & 105 deletions
This file was deleted.

aws/configs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
AWS_CREDENTIALS_FILE=/home/yadu/.ssh/boto-test-credentials.csv
22
AWS_KEYPAIR_NAME=boto-test-pair
3+
AWS_KEYPAIR_FILE=/home/yadu/.ssh/boto-test-pair.pem
4+
5+
#ec2-user is the default user on Amazon linux
6+
#AWS_USERNAME=ec2-user
37

48
AWS_REGION=us-west-2
59

6-
# Ami for headnode
7-
# Clean Ubuntu 14.04 image
8-
# HEADNODE_IMAGE=ami-68c2a858
9-
# Amazon linux x86_64
10-
HEADNODE_IMAGE=ami-1b3b462b
10+
# Amazon linux x86_64 with Swift and JDK
11+
HEADNODE_IMAGE=ami-f1e896c1
1112

1213
HEADNODE_MACHINE_TYPE=t1.micro
1314

14-
SECURITY_GROUP=default
15+
SECURITY_GROUP=swift_security_group1
1516

17+
WORKER_MACHINE_TYPE=t1.micro
1618
# Ami for workers
17-
WORKER_IMAGE=todo
19+
WORKER_IMAGE=ami-f1e896c1
File renamed without changes.
File renamed without changes.

aws/libcloud/configs

Lines changed: 0 additions & 19 deletions
This file was deleted.

aws/setup.sh

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
#!/bin/bash
2+
3+
LOG=Setup_$$.log
4+
5+
# Is this valid/required for AWS ?
6+
check_project ()
7+
{
8+
RESULT=$(gcutil listinstances --project=$GCE_PROJECTID 2>&1)
9+
}
10+
11+
12+
start_worker ()
13+
{
14+
echo "Starting worker - TODO"
15+
}
16+
17+
# Is this valid for AWS ?
18+
check_keys ()
19+
{
20+
echo "Check_keys - TODO"
21+
[[ ! -f ~/.ssh/google_compute_engine ]] && echo "Google private key missing" && return
22+
[[ ! -f ~/.ssh/google_compute_engine.pub ]] && echo "Google public key missing" && return
23+
}
24+
25+
26+
stop_workers()
27+
{
28+
echo "Stopping all instances"
29+
}
30+
31+
32+
stop_n_workers()
33+
{
34+
COUNT=1
35+
[[ ! -z "$1" ]] && COUNT=$1
36+
echo "Stopping $COUNT instances"
37+
INSTANCES=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | awk '{print $2}' | tail -n $COUNT)
38+
gcutil --project=$GCE_PROJECTID deleteinstance $INSTANCES --delete_boot_pd --force
39+
}
40+
41+
42+
# Start N workers in parallel ?
43+
# This script ensures that only the specified number of workers are active
44+
start_n_workers ()
45+
{
46+
COUNT=$1
47+
CURRENT=1
48+
out=$(gcutil --project=$GCE_PROJECTID listinstances | grep "swift-worker")
49+
if [[ "$?" == 0 ]]
50+
then
51+
echo "Current workers"
52+
echo "${out[*]}"
53+
CURRENT=$(gcutil --project=$GCE_PROJECTID listinstances | grep "swift-worker" | wc -l)
54+
echo "Count : " $CURRENT
55+
echo "New workers needed : $(($COUNT - $CURRENT))"
56+
fi
57+
58+
for i in $(seq $CURRENT 1 $COUNT)
59+
do
60+
start_worker $i &> $LOG &
61+
done
62+
wait
63+
gcutil --project=$GCE_PROJECTID listinstances
64+
echo "Updating WORKER_HOSTS"
65+
EXTERNAL_IPS=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | awk '{print $10}')
66+
WORKER_NAMES=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | awk '{print $2}')
67+
}
68+
69+
start_n_more ()
70+
{
71+
setup_images
72+
ACTIVE=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | wc -l)
73+
MORE=$1
74+
for i in $(seq $(($ACTIVE+1)) 1 $(($ACTIVE+$MORE)) )
75+
do
76+
echo "Starting worker $i"
77+
start_worker $i &> $LOG &
78+
done
79+
wait
80+
gcutil --project=$GCE_PROJECID listinstances
81+
echo "Updating WORKER_HOSTS"
82+
EXTERNAL_IPS=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | awk '{print $10}')
83+
WORKER_NAMES=$(gcutil --project=$GCE_PROJECTID listinstances | grep worker | awk '{print $2}')
84+
}
85+
86+
stop_headnode()
87+
{
88+
echo "Stopping headnode"
89+
gcutil --project=$GCE_PROJECTID deleteinstance "headnode" --delete_boot_pd --force
90+
}
91+
92+
add_image()
93+
{
94+
gcutil --project=$GCE_PROJECTID addimage $1 $2
95+
}
96+
97+
setup_images()
98+
{
99+
echo "Checking images"
100+
IFS=$'\n\r'; image_list=($(gcutil --project=$GCE_PROJECTID listimages | grep -o "swift-[^\ ]*"))
101+
#echo ${image_list[*]}
102+
if [[ $HEADNODE_IMAGE == $DEPOT_PREFIX* ]]
103+
then
104+
HEADNODE_IMAGE_ID="swift-headnode-image-$(echo ${HEADNODE_IMAGE%.image.tar.gz} | tail -c 6)"
105+
echo ${image_list[*]} | grep -o $HEADNODE_IMAGE_ID &> /dev/null
106+
if [[ "$?" == "0" ]]
107+
then # The image is already added to the project
108+
echo "$HEADNODE_IMAGE_ID present"
109+
else # The image is not present and needs to be added
110+
echo "Adding image $HEADNODE_IMAGE_ID"
111+
add_image $HEADNODE_IMAGE_ID $HEADNODE_IMAGE
112+
fi
113+
else
114+
echo "Not from swift-worker"
115+
fi
116+
117+
if [[ $WORKER_IMAGE == $DEPOT_PREFIX* ]]
118+
then
119+
WORKER_IMAGE_ID="swift-worker-image-$(echo ${WORKER_IMAGE%.image.tar.gz} | tail -c 6)"
120+
echo ${image_list[*]} | grep -o $WORKER_IMAGE_ID &> /dev/null
121+
if [[ "$?" == "0" ]]
122+
then # The image is already added to the project
123+
echo "$WORKER_IMAGE_ID present"
124+
else # The image is not present and needs to be added
125+
echo "Adding image $WORKER_IMAGE_ID"
126+
add_image $WORKER_IMAGE_ID $WORKER_IMAGE
127+
fi
128+
else
129+
echo "Not from $DEPOT_PREFIX"
130+
fi
131+
132+
}
133+
134+
setup_firewall()
135+
{
136+
echo "Checking for swift firewall rules"
137+
gcutil --project=$GCE_PROJECTID listfirewalls | grep swift-ports
138+
if [[ "$?" == "0" ]]
139+
then
140+
echo "Firewall present"
141+
else
142+
echo "Creating firewall"
143+
gcutil --project=$GCE_PROJECTID addfirewall swift-ports --network=default \
144+
--allowed=tcp:50000-60000,udp:50000-60000 \
145+
--allowed_ip_sources='0.0.0.0/0'
146+
fi
147+
}
148+
149+
generate_swiftproperties()
150+
{
151+
EXTERNAL_IP=$(gcutil --project=$GCE_PROJECTID listinstances | grep headnode | awk '{ print $10 }')
152+
SERVICE_PORT=50010
153+
echo http://$EXTERNAL_IP:$SERVICE_PORT > PUBLIC_ADDRESS
154+
cat <<EOF > swift.properties
155+
site=cloud,local
156+
use.provider.staging=true
157+
execution.retries=2
158+
159+
site.local {
160+
jobmanager=local
161+
initialScore=10000
162+
filesystem=local
163+
workdir=/tmp/swiftwork
164+
}
165+
166+
site.cloud {
167+
taskWalltime=04:00:00
168+
initialScore=10000
169+
filesystem=local
170+
jobmanager=coaster-persistent:local:local:http://$EXTERNAL_IP:$SERVICE_PORT
171+
workerManager=passive
172+
taskThrottle=800
173+
workdir=/home/$USER/work
174+
}
175+
176+
EOF
177+
}
178+
179+
list_resources()
180+
{
181+
gcutil --project=$GCE_PROJECTID listinstances # | grep worker | awk '{print $2}'
182+
}
183+
184+
dissolve()
185+
{
186+
stop_headnode;
187+
stop_workers;
188+
}
189+
190+
connect()
191+
{
192+
source configs
193+
NODE=$1
194+
[[ -z $1 ]] && NODE="headnode"
195+
[[ -z $AWS_USERNAME ]] && AWS_USERNAME="ec2-user"
196+
197+
IP=$(./aws.py list_resource $NODE)
198+
echo "Connecting to AWS node:$NODE on $IP as $AWS_USERNAME"
199+
ssh -A -o StrictHostKeyChecking=no -l $AWS_USERNAME -i $AWS_KEYPAIR_FILE $IP
200+
}
File renamed without changes.

aws/worker_userdata

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
HEADNODE=SET_HEADNODE_IP
3+
WORKERPORT="50005"
4+
#Ping timeout
5+
PTIMEOUT=4
6+
export JAVA=/usr/local/bin/jdk1.7.0_51/bin
7+
export SWIFT=/usr/local/bin/swift-0.95-RC6/bin
8+
export PATH=$JAVA:$SWIFT:$PATH
9+
worker_loop ()
10+
{
11+
while :
12+
do
13+
echo "Pinging HEADNODE on $HEADNODE"
14+
worker.pl http://$HEADNODE:$WORKERPORT 0099 ~/workerlog -w 3600
15+
sleep 5
16+
done
17+
}
18+
worker_loop &

0 commit comments

Comments
 (0)