forked from mhausenblas/dromedar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dromedar.py
executable file
·60 lines (44 loc) · 1.52 KB
/
dromedar.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
53
54
55
56
57
58
59
60
#!/usr/bin/env python
"""
Provisions Apache Drill on all Mesos worker nodes and launches qsf.py via Marathon.
Usage:
./dromedar.py $MARATHON_URL
Example:
./dromedar.py http://localhost:8080
@author: Michael Hausenblas, http://mhausenblas.info/#i
@since: 2015-04-12
@status: init
"""
import logging
import os
import sys
import time
from marathon import MarathonClient
from marathon.models import MarathonApp
################################################################################
# Defaults
#
DEBUG = True
if DEBUG:
FORMAT = '%(asctime)-0s %(levelname)s %(message)s [at line %(lineno)d]'
logging.basicConfig(level=logging.DEBUG, format=FORMAT, datefmt='%Y-%m-%dT%I:%M:%S')
else:
FORMAT = '%(asctime)-0s %(message)s'
logging.basicConfig(level=logging.INFO, format=FORMAT, datefmt='%Y-%m-%dT%I:%M:%S')
def launch_qsf(marathon_url):
logging.info('Launching QSF using %s' %(marathon_url))
# launch via Marathon REST API
c = MarathonClient(marathon_url)
c.create_app('dromedar-qsf', MarathonApp(cmd='python dromedar-master/qsf.py %s' %(marathon_url), uris=['https://github.com/mhausenblas/dromedar/archive/master.zip'], mem=100, cpus=.5))
logging.info('QSF up and running.')
################################################################################
# Main script
#
if __name__ == '__main__':
try:
marathon_url = sys.argv[1] # Marathon URL to use
launch_qsf(marathon_url)
except Exception, e:
print(e)
print(__doc__)
sys.exit(2)