Skip to content

Commit 5e45038

Browse files
committed
Moved the userdata logic to configurator.py file.
1 parent c4ff8fb commit 5e45038

File tree

8 files changed

+80
-76
lines changed

8 files changed

+80
-76
lines changed

aws/README.asc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
Swift cloud on Amazon Web Services
2-
----------------------------------
3-
4-
1+
Swift cloud on Amazon Elastic Compute Cloud
2+
-------------------------------------------
53

64

75
Sign up online
@@ -17,24 +15,33 @@ Password Policy and Credentials in Using IAM.
1715
1816
2. From the navigation menu, click Users.
1917
20-
3. Select your IAM user name.
18+
3. Select your IAM user name, or create a new one.
2119
2220
4. Click User Actions, and then click Manage Access Keys.
2321
2422
5. Click Create Access Key.
2523
2624
Note: Your keys will look something like this: +
27-
Access key ID example: AKIAIOSFODNN7EXAMPLE +
25+
Access key ID example : AKIAIOSFODNN7EXAMPLE +
2826
Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY +
2927

30-
6. Click Download Credentials, and store the keys in a secure location.
28+
6. Click Download Credentials, and store the keys (a .csv file) in a secure location.
3129
32-
Your secret key will no longer be available through the AWS Management Console; you will have the only copy. Keep it confidential in order to protect your account, and never email it. Do not share it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.
33-
* TODO
30+
NOTE: Your secret key will no longer be available through the AWS Management Console;
31+
you will have the only copy. Keep it confidential in order to protect your account,
32+
and never email it.
3433

3534
Setup local-machine
3635
^^^^^^^^^^^^^^^^^^^
3736

37+
Get the swift-on-cloud repository from git
38+
[source,bash]
39+
-----
40+
git clone git@github.com:yadudoc/swift-on-cloud.git
41+
cd swift-on-cloud/aws
42+
-----
43+
44+
3845
* TODO
3946
4047
Manage you Cloud resources

aws/aws.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ def create_security_group(ec2_driver):
6565
print res
6666

6767
def start_headnode(driver, configs):
68-
#userdata = "\n".join(open("headnode_userdata").readlines())
69-
userdata = open("headnode_userdata").read()
68+
userdata = configurator.getstring("headnode")
7069

7170
size = NodeSize(id=configs['HEADNODE_MACHINE_TYPE'], name='headnode',
7271
ram=None, disk=None, bandwidth=None, price=None, driver=driver)
@@ -94,9 +93,11 @@ def start_worker(driver, configs, worker_names):
9493
return -1
9594

9695
# Setup userdata
97-
userdata = open("worker_userdata").read()
96+
userdata = configurator.getstring("headnode")
9897
userdata = userdata.replace("SET_HEADNODE_IP", headnode.public_ips[0])
9998

99+
print userdata
100+
100101
list_nodes = []
101102
for worker_name in worker_names:
102103
size = NodeSize(id=configs['WORKER_MACHINE_TYPE'], name=worker_name,
@@ -179,6 +180,9 @@ def help():
179180
worker_name = args[1]
180181
start_worker(driver,configs,[worker_name])
181182

183+
elif args[0] == "check_keys":
184+
check_keys(driver,configs)
185+
182186
elif args[0] == "start_headnode":
183187
start_headnode(driver,configs)
184188

aws/configs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
AWS_CREDENTIALS_FILE=/home/yadu/.ssh/boto-test-credentials.csv
1+
AWS_CREDENTIALS_FILE=~/.ssh/boto-test-credentials.csv
22
AWS_KEYPAIR_NAME=boto-test-pair
3-
AWS_KEYPAIR_FILE=/home/yadu/.ssh/boto-test-pair.pem
3+
AWS_KEYPAIR_FILE=~/.ssh/boto-test-pair.pem
44

55
#ec2-user is the default user on Amazon linux
66
#AWS_USERNAME=ec2-user

aws/configurator.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def read_configs(config_file):
2626
config = _read_conf(config_file)
2727

2828
if 'AWS_CREDENTIALS_FILE' in config :
29+
config['AWS_CREDENTIALS_FILE'] = os.path.expanduser(config['AWS_CREDENTIALS_FILE'])
30+
config['AWS_CREDENTIALS_FILE'] = os.path.expandvars(config['AWS_CREDENTIALS_FILE'])
2931

30-
#print "Credentials file = ", config['AWS_CREDENTIALS_FILE']
3132
cred_lines = open(config['AWS_CREDENTIALS_FILE']).readlines()
3233
cred_details = cred_lines[1].split(',')
3334
credentials = { 'AWS_Username' : cred_details[0],
@@ -36,8 +37,60 @@ def read_configs(config_file):
3637
config.update(credentials)
3738
else:
3839
print "AWS_CREDENTIALS_FILE , Missing"
39-
return "AWS_CREDENTIAL_MISSING"
40+
print "ERROR: Cannot proceed without access to AWS_CREDENTIALS_FILE"
41+
exit(-1)
4042

43+
if 'AWS_KEYPAIR_FILE' in config:
44+
config['AWS_KEYPAIR_FILE'] = os.path.expanduser(config['AWS_CREDENTIALS_FILE'])
45+
config['AWS_KEYPAIR_FILE'] = os.path.expandvars(config['AWS_CREDENTIALS_FILE'])
4146
return config
4247

4348
#configs = read_configs("./configs")
49+
#pretty_configs(configs)
50+
51+
#!/usr/bin/env python
52+
53+
HEADNODE_USERDATA='''#!/bin/bash
54+
WORKERPORT="50005"; SERVICEPORT="50010"
55+
export JAVA=/usr/local/bin/jdk1.7.0_51/bin
56+
export SWIFT=/usr/local/bin/swift-0.95-RC6/bin
57+
export PATH=$JAVA:$SWIFT:$PATH
58+
coaster_loop ()
59+
{
60+
while :
61+
do
62+
coaster-service -p $SERVICEPORT -localport $WORKERPORT -nosec -passive &> /var/log/coaster-service.logs
63+
sleep 10;
64+
done
65+
}
66+
coaster_loop &
67+
'''
68+
69+
WORKER_USERDATA='''#!/bin/bash
70+
HEADNODE=SET_HEADNODE_IP
71+
WORKERPORT="50005"
72+
#Ping timeout
73+
PTIMEOUT=4
74+
export JAVA=/usr/local/bin/jdk1.7.0_51/bin
75+
export SWIFT=/usr/local/bin/swift-0.95-RC6/bin
76+
export PATH=$JAVA:$SWIFT:$PATH
77+
worker_loop ()
78+
{
79+
while :
80+
do
81+
echo "Pinging HEADNODE on $HEADNODE"
82+
worker.pl http://$HEADNODE:$WORKERPORT 0099 ~/workerlog -w 3600
83+
sleep 5
84+
done
85+
}
86+
worker_loop &
87+
'''
88+
89+
def getstring(target):
90+
if target == "headnode":
91+
return HEADNODE_USERDATA
92+
elif target == "worker":
93+
return WORKER_USERDATA
94+
else:
95+
return -1
96+

aws/headnode_userdata

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

aws/userdata.sh

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

aws/worker_userdata

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

compute-engine/README.asc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ git clone git@github.com:yadudoc/swift-on-cloud.git
3636
cd swift-on-cloud/compute-engine
3737
-----
3838

39-
40-
4139
Manage you Cloud resources
4240
^^^^^^^^^^^^^^^^^^^^^^^^^^
4341

0 commit comments

Comments
 (0)