This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-deployment.py
68 lines (56 loc) · 2.09 KB
/
run-deployment.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
61
62
63
64
65
66
67
#!/usr/bin/env python
import aiofiles
import argparse
import asyncio
import inspect
import logging
import os
import typing
from quine import \
tail_constants as constants_quine, \
tail_common as common_quine, \
tail_deployment as deployment_quine
logger = logging.getLogger(__name__)
def capture_options() -> typing.Any:
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--deployment-type', default=constants_quine.DeploymentType.NOOP, type=constants_quine.DeploymentType)
parser.add_argument('-b', '--database-deployment-type', default=constants_quine.DatabaseDeploymentType.NOOP, type=constants_quine.DatabaseDeploymentType)
parser.add_argument('-c', '--cache-deployment-type', default=constants_quine.CacheDeploymentType.NOOP, type=constants_quine.CacheDeploymentType)
return parser.parse_args()
async def run_deployment() -> typing.Dict[str, typing.Any]:
call_chain = (
common_quine.map_deployment_ips,
common_quine.map_aws_route53,
common_quine.map_aws_images,
common_quine.map_aws_vpcs,
common_quine.map_aws_ips,
common_quine.map_aws_rds,
common_quine.map_aws_elasticache,
common_quine.map_aws_subnets,
common_quine.map_aws_security_groups,
common_quine.map_aws_instances,
#deployment_quine.clear_containers,
deployment_quine.sync_containers,
deployment_quine.deploy,)
#deployment_quine.clear_images,)
with common_quine.obtain_executor() as executor:
payload: typing.Dict[str, typing.Any] = {
'options': capture_options(),
}
for operation in call_chain:
if inspect.iscoroutinefunction(operation):
await operation(executor, payload)
else:
task = executor.submit(operation, executor, payload)
while not task.done() is True:
await asyncio.sleep(.1)
try:
task.result()
except Exception as err:
raise err
return payload
async def main() -> None:
cluster_info = await run_deployment()
if __name__ in ['__main__']:
event_loop = common_quine.obtain_event_loop()
event_loop.run_until_complete(main())