async def run_deployment() -> typing.Dict[str, typing.Any]: call_chain = ( common_quine.map_cloudfront, common_quine.map_buckets, common_quine.map_acm, common_quine.map_aws_route53, common_quine.sync_bucket_for_client, common_quine.sync_aws_acm_for_client, common_quine.map_acm, common_quine.sync_cloudfront_for_client, ) 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 run_deployment() -> typing.Dict[str, typing.Any]: call_chain = ( build_quine.build, build_quine.ops, build_quine.webservice,) 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: options = capture_options() with common_quine.obtain_executor() as executor: results = [] results.append( executor.submit(common_quine.create_dir_of_path, options.output_path)) results.append(executor.submit(common_quine.obtain_jinja2_env)) while not all([item.done() for item in results]): await asyncio.sleep(.1) template = """#!/usr/bin/env bash export DEPLOYMENT="{{constants_quine.DEPLOYMENT}}" export STAGE="{{constants_quine.STAGE}}" export VERSION="{{constants_quine.VERSION}}" {% for var_name, value in constants_quine.ENV_VARS.items() %} export {{var_name}}="{{value}}" {% endfor %} """ template = constants_quine.JINJA2_ENV.from_string(template) template_context = {key: globals()[key] for key in ['constants_quine']} output = template.render(template_context) logger.info(f'Writing ENVVars to path[{options.output_path}]') async with aiofiles.open(options.output_path, 'w') as stream: await stream.write(output)
async def launch_cluster() -> 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, common_quine.sync_aws_expectations) 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 launch_services( cluster_info: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]: call_chain = ( services_quine.generate_ssh_configs, services_quine.generate_ssh_knownhosts, services_quine.install_docker_runtime, services_quine.force_reboot, services_quine.install_docker_registry, ) 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, cluster_info) else: task = executor.submit(operation, executor, payload, cluster_info) while not task.done() is True: await asyncio.sleep(.1) try: task.result() except Exception as err: raise err return payload
async def execute_call_chain( cluster_info: typing.Dict[str, typing.Any], call_chain: typing.List[typing.Callable] ) -> typing.Dict[str, typing.Any]: with common_quine.obtain_executor() as executor: for operation in call_chain: if inspect.iscoroutinefunction(operation): await operation(executor, cluster_info) else: task = executor.submit(operation, executor, cluster_info) while not task.done() is True: await asyncio.sleep(.1) try: task.result() except Exception as err: raise err return cluster_info
async def main() -> None: options = capture_options() with common_quine.obtain_executor() as executor: results = [] results.append( executor.submit(common_quine.create_dir_of_path, options.output_path)) results.append(executor.submit(common_quine.obtain_jinja2_env)) while not all([item.done() for item in results]): await asyncio.sleep(.1) async with aiofiles.open(options.output_path, 'w') as output_stream: async with aiofiles.open(options.template_path, 'r') as stream: template = await stream.read() template = constants_quine.JINJA2_ENV.from_string(template) template_context = { key: globals()[key] for key in ['constants_quine'] } output = template.render(template_context) logger.info(f'Writing File to Path[{options.output_path}]') await output_stream.write(output)
async def execute_map_call_chain( call_chain: typing.List[typing.Callable] ) -> typing.Dict[str, typing.Any]: with common_quine.obtain_executor() as executor: payload = { '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