-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdreadnot.deploy
62 lines (48 loc) · 1.92 KB
/
dreadnot.deploy
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
61
62
#!/bin/env python
# commandline deployer for dreadnot
import os
import requests
from optparse import OptionParser
from ConfigParser import SafeConfigParser
# config file should be ini format
def configure(config_file, env):
config = {}
conf = SafeConfigParser()
if conf.read(config_file):
config['username'] = conf.get(env, 'username')
config['password'] = conf.get(env, 'password')
config['dreadnot'] = conf.get(env, 'dreadnot')
config['region'] = conf.get(env, 'region')
else:
print 'No configuration found'
return config
# deploy the goodness
def deploy(dreadnot, username, password, region, app_name, revision,
ssl_verify=False):
DREADNOT_DEPLOY = '%s/api/1.0/stacks/%s/regions/%s/deployments' % (dreadnot, app_name, region)
TO_REVISION = {'to_revision': revision}
r = requests.post(DREADNOT_DEPLOY, data=TO_REVISION,
auth=(username, password), verify=ssl_verify)
def main():
parser = OptionParser(usage="usage: %prog [options] app_name")
parser.add_option("-c", "--conf",
default='/etc/dreadnot.webdeployer',
type='string',
help="Configuration File")
parser.add_option("-e", "--environment",
default='dev',
type='string',
help="Environment you want to deploy to")
parser.add_option("-r", "--revision",
default='origin/master',
type='string',
help="Git Revision")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.error("wrong number of arguments")
app_name = args[0]
config = configure(options.conf, options.environment)
deploy(config['dreadnot'], config['username'], config['password'],
config['region'], app_name, options.revision)
if __name__ == '__main__':
main()