This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathopenshift-deploy
executable file
·87 lines (78 loc) · 2.42 KB
/
openshift-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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
import logging
import logging.config
from app import BASE_DIR, SUPPORTED_CONTAINER_RUNTIMES
from app import ContainerRuntimeMissingError
from app.cli import OpenShiftDeployCLI
from app.deploy import OpenShiftDeploy
from app.bundle import OpenShiftBundle
LOGGING_CONFIG = {
'version': 1,
'formatters': {
'simple': {
'format': '%(asctime)-8s | %(levelname)-8s | %(name)-10s | %(message)s',
'datefmt': '%H:%M:%S',
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
},
},
'loggers': {
'app': {
'level': 'DEBUG',
'handlers': [
'console',
],
'propagate': 'no',
},
},
}
logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger('app')
if __name__ == '__main__':
cli = OpenShiftDeployCLI()
known_args, extra_args = cli.parse_known_args()
try:
if known_args.action == 'bundle':
ob = OpenShiftBundle(
vars_file=known_args.vars_file,
bundle_dir=known_args.bundle_dir,
)
else:
od = OpenShiftDeploy(
vars_file=known_args.vars_file,
)
except ContainerRuntimeMissingError:
print('\n'.join([
'You do not have a supported container runtime installed.',
'',
'This script supports the following container runtimes:',
'\n'.join(' - {}'.format(i) for i in SUPPORTED_CONTAINER_RUNTIMES),
'',
'Please install one of those options and try again.'
]))
if known_args.action == 'build':
od.build()
elif known_args.action == 'shell':
od.shell()
elif known_args.action == 'bundle':
if known_args.bundle_action == 'export':
ob.export_bundle(extra_args)
# elif known_args.bundle_action == 'import':
# ob.import_bundle(extra_args)
elif known_args.action == 'create':
od.create(extra_args)
elif known_args.action == 'destroy':
od.destroy(extra_args)
elif known_args.action == 'start':
od.start(extra_args)
elif known_args.action == 'stop':
od.stop(extra_args)
elif known_args.action == 'info':
od.info(extra_args)
elif known_args.action == 'ssh':
od.ssh()