-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.py
More file actions
executable file
·59 lines (44 loc) · 1.78 KB
/
Copy pathdeploy.py
File metadata and controls
executable file
·59 lines (44 loc) · 1.78 KB
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
#!/usr/bin/env python
import argparse
# coding: utf-8
__Author__ = 'Yufei Ren'
__Date__ = '2017.07.11'
USAGE = '''
Usage:
deploy.py {env} {container} {tag}
Example:
deploy.py dev kiwi-ghost 0.0.1
'''
def init_args(input_vars):
command_vars = {}
command_vars.update(vars(input_vars))
if not input_vars.host_limit:
command_vars['host_limit'] = ''
if not input_vars.ip_limit:
command_vars['ip_limit'] = ''
if input_vars.no_cache:
command_vars['cache'] = 'disable'
else:
command_vars['cache'] = 'enable'
command_vars.pop('no_cache')
if input_vars.debug:
command_vars['command'] = '/bin/bash'
command_vars['tty'] = 'true'
else:
command_vars['command'] = ''
command_vars['tty'] = 'false'
command_vars.pop('debug')
print command_vars
if __name__ == '__main__':
parser = argparse.ArgumentParser(prog='deploy.py',
description='this command for deploy docker image to aws')
parser.add_argument('env', help='environment: dev, qa, ppe, prod')
parser.add_argument('container', help='docker container: kiwi-ghost ...')
parser.add_argument('tag', help='docker image tag: 0.0.1, CKB-1000 ...')
parser.add_argument('-host', '--host_limit', help='limit host name to install, without env: -host blog')
parser.add_argument('-ip', '--ip_limit', help='limit ip to install: -ip 10.10.1.2')
parser.add_argument('-n', '--no_cache', action='store_true',
help='disable apache page cache, works only for apache container')
parser.add_argument('-d', '--debug', action='store_true',
help='enable debug model for container, start with container with /bin/bash')
init_args(parser.parse_args())