-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
52 lines (44 loc) · 1.55 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from path import path as pathpy
from fabric.api import *
from fabric.contrib.console import confirm
env.key_filename = 'ec2-arborean.pem'
CLUSTER = {}
def cluster(name):
global CLUSTER
CLUSTER = ns = {'NAME': name}
with open('%s-settings.py' % name) as fp:
exec fp in ns
env.roledefs['server'] = [ 'ubuntu@' + ns['SERVER_PUBLIC'] ]
env.roledefs['client'] = [ 'ubuntu@' + ns['CLIENT_PUBLIC'] ]
def uname():
run('uname -a')
@roles('server')
def prepare_server():
sudo('apt-get install -y mongodb-server')
put('mongodb.conf', '/etc/mongodb.conf', use_sudo=True)
sudo('service mongodb restart')
@roles('server')
def prepare_server_22():
put('10gen.list', '/etc/apt/sources.list.d', use_sudo=True)
sudo('apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10')
sudo('apt-get update')
sudo('apt-get install -y mongodb-10gen')
put('mongodb.conf', '/etc/mongodb.conf', use_sudo=True)
sudo('service mongodb restart')
@roles('client')
def prepare_client():
sudo('apt-get install -y python-dev python-virtualenv mongodb-clients')
run('virtualenv sdas')
run('sdas/bin/pip install pymongo')
put('writer.py', 'writer.py')
@roles('client')
def run_client(runtype):
try:
run('sdas/bin/python writer.py mongodb://%s:27017 %s' % (
CLUSTER['SERVER_PRIVATE'], runtype))
except KeyboardInterrupt:
get('times.csv', 'times-%s-%s.csv' % (CLUSTER['NAME'], runtype))
raise
@roles('client')
def get_times():
get('times.csv', 'times-%s.csv' % (CLUSTER['NAME']))