<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import argparse <EOL> import getpass <EOL> import json <EOL> import os <EOL> import re <EOL> import socket <EOL> import struct <EOL> import sys <EOL> import time <EOL> import boto . cloudformation <EOL> import boto . ec2 <EOL> import boto . s3 <EOL> import elasticluster <EOL> import requests <EOL> from bcbiovm . aws import common <EOL> ICEL_TEMPLATES = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> def setup_cmd ( awsparser ) : <EOL> parser_c = awsparser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> icel_parser = parser_c . add_subparsers ( title = "<STR_LIT>" ) <EOL> parser = icel_parser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> formatter_class = argparse . ArgumentDefaultsHelpFormatter ) <EOL> parser = common . add_default_ec_args ( parser ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , default = False , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store_true>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT>" , default = True , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = int , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = int , default = "<STR_LIT:4>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = int , default = "<STR_LIT:4>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , metavar = "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT>" % getpass . getuser ( ) , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( metavar = "<STR_LIT>" , dest = "<STR_LIT>" , nargs = "<STR_LIT:?>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( func = create ) <EOL> parser = icel_parser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> formatter_class = argparse . ArgumentDefaultsHelpFormatter ) <EOL> parser = common . add_default_ec_args ( parser ) <EOL> parser . add_argument ( metavar = "<STR_LIT>" , dest = "<STR_LIT>" , nargs = "<STR_LIT:?>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( func = fs_spec ) <EOL> parser = icel_parser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> formatter_class = argparse . ArgumentDefaultsHelpFormatter ) <EOL> parser = common . add_default_ec_args ( parser ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT>" , default = True , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( metavar = "<STR_LIT>" , dest = "<STR_LIT>" , nargs = "<STR_LIT:?>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( func = mount ) <EOL> parser = icel_parser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> formatter_class = argparse . ArgumentDefaultsHelpFormatter ) <EOL> parser = common . add_default_ec_args ( parser ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT>" , default = True , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( metavar = "<STR_LIT>" , dest = "<STR_LIT>" , nargs = "<STR_LIT:?>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( func = unmount ) <EOL> parser = icel_parser . add_parser ( "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> formatter_class = argparse . ArgumentDefaultsHelpFormatter ) <EOL> parser = common . add_default_ec_args ( parser ) <EOL> parser . add_argument ( metavar = "<STR_LIT>" , dest = "<STR_LIT>" , nargs = "<STR_LIT:?>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( func = stop ) <EOL> def create ( args ) : <EOL> if args . network : <EOL> cidr_regex = r'<STR_LIT>' <EOL> if not re . search ( cidr_regex , args . network ) : <EOL> sys . stderr . write ( <EOL> '<STR_LIT>' . format ( <EOL> args . network ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> config = common . ecluster_config ( args . econfig ) <EOL> cluster_config = config . cluster_conf [ args . cluster ] <EOL> try : <EOL> cluster = config . load_cluster ( args . cluster ) <EOL> cluster_storage_path = cluster . repository . storage_path <EOL> except elasticluster . exceptions . ClusterNotFound : <EOL> cluster_storage_path = common . get_storage_dir ( args . econfig ) <EOL> if not os . path . exists ( cluster_storage_path ) : <EOL> os . makedirs ( cluster_storage_path ) <EOL> if not args . setup : <EOL> icel_param = { <EOL> '<STR_LIT>' : args . oss_count , <EOL> '<STR_LIT>' : args . size / args . oss_count / args . lun_count , <EOL> '<STR_LIT>' : args . lun_count , <EOL> } <EOL> template_url = _upload_icel_cf_template ( <EOL> icel_param , args . bucket , cluster_config [ '<STR_LIT>' ] ) <EOL> _create_stack ( <EOL> args . stack_name , template_url , args . network , <EOL> args . cluster , cluster_config , args . recreate ) <EOL> try : <EOL> sys . stdout . write ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> sys . stdout . flush ( ) <EOL> _wait_for_stack ( args . stack_name , '<STR_LIT>' , <EOL> <NUM_LIT:15> * <NUM_LIT> , cluster_config [ '<STR_LIT>' ] ) <EOL> except Exception as e : <EOL> sys . stderr . write ( '<STR_LIT>' . format ( str ( e ) ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> ssh_config_path = os . path . join ( <EOL> cluster_storage_path , '<STR_LIT>' . format ( args . stack_name ) ) <EOL> _write_ssh_config ( ssh_config_path , args . stack_name , cluster_config ) <EOL> ansible_config_path = os . path . join ( <EOL> cluster_storage_path , <EOL> '<STR_LIT>' . format ( args . stack_name ) ) <EOL> _write_ansible_config ( <EOL> ansible_config_path , args . stack_name , cluster_storage_path ) <EOL> inventory_path = os . path . join ( <EOL> cluster_storage_path , <EOL> '<STR_LIT>' . format ( args . stack_name ) ) <EOL> _write_inventory ( inventory_path , args . stack_name , cluster_config [ '<STR_LIT>' ] ) <EOL> playbook_path = os . path . join ( <EOL> common . ANSIBLE_BASE , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> common . run_ansible_pb ( <EOL> inventory_path , playbook_path , args , ansible_cfg = ansible_config_path ) <EOL> def fs_spec ( args ) : <EOL> cluster_config = common . ecluster_config ( args . econfig , args . cluster ) <EOL> print ( _get_fs_spec ( args . stack_name , cluster_config [ '<STR_LIT>' ] ) ) <EOL> def mount ( args ) : <EOL> mount_or_unmount ( args , True ) <EOL> def unmount ( args ) : <EOL> mount_or_unmount ( args , False ) <EOL> def mount_or_unmount ( args , mount = True ) : <EOL> cluster = common . ecluster_config ( args . econfig ) . load_cluster ( args . cluster ) <EOL> inventory_path = os . path . join ( <EOL> cluster . repository . storage_path , <EOL> '<STR_LIT>' . format ( args . cluster ) ) <EOL> if mount : <EOL> playbook_file = "<STR_LIT>" <EOL> else : <EOL> playbook_file = "<STR_LIT>" <EOL> playbook_path = os . path . join ( <EOL> common . ANSIBLE_BASE , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , playbook_file ) <EOL> def get_lustre_vars ( args , cluster_config ) : <EOL> return { '<STR_LIT>' : _get_fs_spec ( <EOL> args . stack_name , cluster_config [ '<STR_LIT>' ] ) } <EOL> common . run_ansible_pb ( <EOL> inventory_path , playbook_path , args , get_lustre_vars ) <EOL> def _template_param ( tree , param ) : <EOL> return [ <EOL> ( i , name ) <EOL> for i , name <EOL> in enumerate ( tree ) <EOL> if type ( name ) in ( str , unicode ) and <EOL> name . startswith ( param ) <EOL> ] [ <NUM_LIT:0> ] <EOL> def _upload_icel_cf_template ( param , bucket_name , aws_config ) : <EOL> url = ICEL_TEMPLATES [ aws_config [ '<STR_LIT>' ] ] <EOL> source_template = requests . get ( url ) <EOL> tree = json . loads ( source_template . text ) <EOL> tree [ '<STR_LIT>' ] = tree [ '<STR_LIT>' ] . replace ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' . format ( param [ '<STR_LIT>' ] ) ) <EOL> if aws_config [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> tree [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . append ( "<STR_LIT>" ) <EOL> tree [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> resources = tree [ '<STR_LIT>' ] <EOL> del resources [ '<STR_LIT>' ] <EOL> del resources [ '<STR_LIT>' ] <EOL> del resources [ '<STR_LIT>' ] <EOL> del resources [ '<STR_LIT>' ] <EOL> resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> item <EOL> for item <EOL> in resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> if item [ '<STR_LIT>' ] != '<STR_LIT>' <EOL> ] <EOL> for section in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> cf_params = resources [ '<STR_LIT>' . format ( section ) ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT:content>' ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> index = _template_param ( cf_params , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> cf_params [ index + <NUM_LIT:1> ] = param [ '<STR_LIT>' ] <EOL> index = _template_param ( cf_params , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> cf_params [ index + <NUM_LIT:1> ] = param [ '<STR_LIT>' ] <EOL> index = _template_param ( cf_params , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> cf_params [ index + <NUM_LIT:1> ] = param [ '<STR_LIT>' ] <EOL> resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = param [ '<STR_LIT>' ] <EOL> resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = param [ '<STR_LIT>' ] <EOL> resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = param [ '<STR_LIT>' ] <EOL> resources [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = param [ '<STR_LIT>' ] <EOL> conn = boto . s3 . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> bucket = conn . create_bucket ( bucket_name ) <EOL> k = boto . s3 . key . Key ( bucket ) <EOL> k . key = '<STR_LIT>' <EOL> k . set_contents_from_string ( json . dumps ( tree ) ) <EOL> k . make_public ( ) <EOL> return k . generate_url ( <NUM_LIT:5> * <NUM_LIT> , query_auth = False ) <EOL> def stop ( args ) : <EOL> cluster_config = common . ecluster_config ( args . econfig , args . cluster ) <EOL> _delete_stack ( args . stack_name , cluster_config ) <EOL> def _delete_stack ( stack_name , cluster_config ) : <EOL> """<STR_LIT>""" <EOL> cf_conn = boto . cloudformation . connect_to_region ( <EOL> cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> aws_access_key_id = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> cf_conn . delete_stack ( stack_name ) <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> sys . stdout . flush ( ) <EOL> _wait_for_stack ( stack_name , '<STR_LIT>' , <EOL> <NUM_LIT:15> * <NUM_LIT> , cluster_config [ '<STR_LIT>' ] ) <EOL> def _create_stack ( stack_name , template_url , lustre_net , cluster , <EOL> cluster_config , recreate ) : <EOL> conn = boto . connect_vpc ( <EOL> aws_access_key_id = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> cf_conn = boto . cloudformation . connect_to_region ( <EOL> cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> aws_access_key_id = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> for stack in cf_conn . list_stacks ( '<STR_LIT>' ) : <EOL> if stack . stack_name == stack_name : <EOL> if recreate : <EOL> _delete_stack ( stack_name , cluster_config ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' . format ( stack_name ) ) <EOL> for vpc in conn . get_all_vpcs ( ) : <EOL> if cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] in [ vpc . tags . get ( '<STR_LIT:Name>' ) , vpc . id ] : <EOL> break <EOL> else : <EOL> raise Exception ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> public_subnet_name = '<STR_LIT>' . format ( cluster ) <EOL> public_subnets = conn . get_all_subnets ( <EOL> filters = { '<STR_LIT>' : vpc . id , '<STR_LIT>' : public_subnet_name } ) <EOL> if len ( public_subnets ) > <NUM_LIT:1> : <EOL> raise Exception ( <EOL> '<STR_LIT>' . format ( <EOL> public_subnet_name , vpc . id , vpc . tags . get ( '<STR_LIT:Name>' ) ) ) <EOL> if len ( public_subnets ) == <NUM_LIT:0> : <EOL> raise Exception ( <EOL> '<STR_LIT>' . format ( <EOL> public_subnet_name , vpc . id , vpc . tags . get ( '<STR_LIT:Name>' ) ) ) <EOL> public_subnet = public_subnets [ <NUM_LIT:0> ] <EOL> if not lustre_net : <EOL> vpc_net = vpc . cidr_block . split ( '<STR_LIT:/>' ) [ <NUM_LIT:0> ] <EOL> vpc_net_int = struct . unpack ( '<STR_LIT>' , socket . inet_aton ( vpc_net ) ) [ <NUM_LIT:0> ] <EOL> lustre_net = socket . inet_ntoa ( struct . pack ( '<STR_LIT>' , vpc_net_int + <NUM_LIT> ) ) <EOL> lustre_net = '<STR_LIT>' . format ( lustre_net ) <EOL> aws_config = cluster_config [ "<STR_LIT>" ] <EOL> cf_conn . create_stack ( stack_name , <EOL> template_url = template_url , <EOL> capabilities = [ '<STR_LIT>' ] , <EOL> parameters = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , vpc . cidr_block ) , <EOL> ( '<STR_LIT>' , "<STR_LIT>" if aws_config [ "<STR_LIT>" ] == "<STR_LIT>" else "<STR_LIT>" ) , <EOL> ( '<STR_LIT>' , vpc . id ) , <EOL> ( '<STR_LIT>' , lustre_net ) , <EOL> ( '<STR_LIT>' , public_subnet . id ) , <EOL> ( '<STR_LIT>' , cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) ) <EOL> def _wait_for_stack ( stack_name , desired_state , wait_for , aws_config ) : <EOL> conn = boto . cloudformation . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> stack = conn . describe_stacks ( stack_name ) [ <NUM_LIT:0> ] <EOL> interval_length = <NUM_LIT:10> <EOL> for interval in xrange ( wait_for / interval_length ) : <EOL> stack . update ( ) <EOL> status = stack . stack_status <EOL> if status == desired_state : <EOL> print ( ) <EOL> return <EOL> elif status . endswith ( '<STR_LIT>' ) : <EOL> sys . stdout . write ( '<STR_LIT:.>' ) <EOL> sys . stdout . flush ( ) <EOL> time . sleep ( interval_length ) <EOL> continue <EOL> else : <EOL> failed_events = [ <EOL> event <EOL> for event <EOL> in stack . describe_events ( ) <EOL> if event . resource_status . endswith ( '<STR_LIT>' ) <EOL> ] <EOL> failed_descr = '<STR_LIT:U+002C>' . join ( [ <EOL> '<STR_LIT>' . format ( <EOL> event . logical_resource_id , event . resource_status_reason ) <EOL> for event <EOL> in failed_events <EOL> ] ) <EOL> print ( ) <EOL> raise Exception ( <EOL> '<STR_LIT>' . format ( <EOL> stack_name , status , failed_descr ) ) <EOL> print ( ) <EOL> def _get_stack_param ( stack_name , param_name , aws_config ) : <EOL> conn = boto . cloudformation . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> icel_stack = conn . describe_stacks ( stack_name ) [ <NUM_LIT:0> ] <EOL> return [ <EOL> param . value <EOL> for param <EOL> in icel_stack . parameters <EOL> if param . key == param_name <EOL> ] <EOL> def get_stack_name ( node_addr , aws_config ) : <EOL> """<STR_LIT>""" <EOL> conn = boto . ec2 . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> reservations = conn . get_all_reservations ( ) <EOL> for resv in reservations : <EOL> for inst in resv . instances : <EOL> if inst . private_ip_address == node_addr : <EOL> return inst . tags [ '<STR_LIT>' ] <EOL> for iface in inst . interfaces : <EOL> iface . update ( ) <EOL> if iface . private_ip_address == node_addr : <EOL> return inst . tags . get ( '<STR_LIT>' ) <EOL> def get_instances ( stack_name , aws_config ) : <EOL> """<STR_LIT>""" <EOL> conn = boto . ec2 . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> reservations = conn . get_all_reservations ( <EOL> filters = { <EOL> '<STR_LIT>' : stack_name , <EOL> } <EOL> ) <EOL> addrs = { } <EOL> for resv in reservations : <EOL> for inst in resv . instances : <EOL> if inst . state in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> continue <EOL> if inst . tags [ '<STR_LIT:Name>' ] == '<STR_LIT>' : <EOL> addrs [ inst . tags [ '<STR_LIT:Name>' ] ] = inst . ip_address <EOL> else : <EOL> addrs [ inst . tags [ '<STR_LIT:Name>' ] ] = inst . private_ip_address <EOL> return addrs <EOL> def _get_mgt_ip_addr ( stack_name , aws_config ) : <EOL> conn = boto . ec2 . connect_to_region ( <EOL> aws_config [ '<STR_LIT>' ] , <EOL> aws_access_key_id = aws_config [ '<STR_LIT>' ] , <EOL> aws_secret_access_key = aws_config [ '<STR_LIT>' ] ) <EOL> reservations = conn . get_all_reservations ( <EOL> filters = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : stack_name , <EOL> } <EOL> ) <EOL> for resv in reservations : <EOL> for inst in resv . instances : <EOL> for iface in inst . interfaces : <EOL> iface . update ( ) <EOL> if iface . tags . get ( '<STR_LIT>' ) == '<STR_LIT>' : <EOL> return iface . private_ip_address <EOL> return inst . private_ip_address <EOL> return None <EOL> def _get_fs_spec ( stack_name , aws_config ) : <EOL> mgt_ipaddr = _get_mgt_ip_addr ( stack_name , aws_config ) <EOL> fs_name = _get_stack_param ( stack_name , '<STR_LIT>' , aws_config ) [ <NUM_LIT:0> ] <EOL> return '<STR_LIT>' . format ( mgt_ipaddr , fs_name ) <EOL> def _write_ssh_config ( path , stack_name , cluster_config ) : <EOL> template_path = os . path . join ( <EOL> common . ANSIBLE_BASE , "<STR_LIT>" ) <EOL> with open ( template_path ) as input : <EOL> ssh_template = input . read ( ) <EOL> instances = get_instances ( stack_name , cluster_config [ '<STR_LIT>' ] ) <EOL> formatted = ssh_template . format ( <EOL> nat_device_ipaddr = instances [ '<STR_LIT>' ] , <EOL> user_key_private = cluster_config [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> ) <EOL> with open ( path , '<STR_LIT:w>' ) as output : <EOL> output . write ( formatted ) <EOL> def _write_inventory ( path , stack_name , aws_config ) : <EOL> instances = get_instances ( stack_name , aws_config ) <EOL> with open ( path , '<STR_LIT:w>' ) as inventory : <EOL> inventory . write ( '<STR_LIT>' ) <EOL> mgts = [ name for name in instances if name . startswith ( '<STR_LIT>' ) ] <EOL> for name in mgts : <EOL> inventory . write ( <EOL> '<STR_LIT>' . format ( <EOL> name , instances [ name ] ) ) <EOL> inventory . write ( '<STR_LIT:\n>' ) <EOL> inventory . write ( '<STR_LIT>' ) <EOL> mdts = [ name for name in instances if name . startswith ( '<STR_LIT>' ) ] <EOL> for name in mdts : <EOL> inventory . write ( <EOL> '<STR_LIT>' . format ( <EOL> name , instances [ name ] ) ) <EOL> inventory . write ( '<STR_LIT:\n>' ) <EOL> inventory . write ( '<STR_LIT>' ) <EOL> osts = [ name for name in instances if name . startswith ( '<STR_LIT>' ) ] <EOL> for name in osts : <EOL> inventory . write ( <EOL> '<STR_LIT>' . format ( <EOL> name , instances [ name ] ) ) <EOL> def _write_ansible_config ( path , stack_name , storage_path ) : <EOL> template_path = os . path . join ( <EOL> common . ANSIBLE_BASE , "<STR_LIT>" ) <EOL> with open ( template_path ) as input : <EOL> ssh_template = input . read ( ) <EOL> formatted = ssh_template . format ( <EOL> cluster_storage_path = storage_path , stack_name = stack_name ) <EOL> with open ( path , '<STR_LIT:w>' ) as output : <EOL> output . write ( formatted ) </s>
