def resolve_roles(env_request, interactive): """ Resolves instance-profile and service-role :param env_request: environment request :param interactive: boolean """ LOG.debug('Resolving roles') if (not env_request.instance_profile or env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME ) and not env_request.template_name: env_request.instance_profile = commonops.create_default_instance_profile( ) if (env_request.platform and env_request.platform.has_healthd_support and not env_request.service_role and not env_request.template_name): role = get_service_role() if role is None: if interactive: io.echo() io.echo(prompts['create.servicerole.info']) input = io.get_input(prompts['create.servicerole.view'], default='') if input.strip('"').lower() == 'view': for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES: document = iam.get_managed_policy_document(policy_arn) io.echo(json.dumps(document, indent=4)) io.get_input(prompts['general.pressenter']) role = create_default_service_role() env_request.service_role = role
def form_vpc_object(self, tier, single): vpc = self.app.pargs.vpc vpc_id = self.app.pargs.vpc_id ec2subnets = self.app.pargs.vpc_ec2subnets elbsubnets = self.app.pargs.vpc_elbsubnets elbpublic = self.app.pargs.vpc_elbpublic publicip = self.app.pargs.vpc_publicip securitygroups = self.app.pargs.vpc_securitygroups dbsubnets = self.app.pargs.vpc_dbsubnets database = self.app.pargs.database if vpc: # Interactively ask for vpc settings io.echo() vpc_id = vpc_id or io.get_input(prompts['vpc.id']) if not tier or tier.is_webserver(): publicip = publicip or io.get_boolean_response( text=prompts['vpc.publicip']) ec2subnets = ec2subnets or io.get_input(prompts['vpc.ec2subnets']) if (not tier or tier.is_webserver()) and not single: elbsubnets = elbsubnets or io.get_input( prompts['vpc.elbsubnets']) elbpublic = elbpublic or io.get_boolean_response( text=prompts['vpc.elbpublic']) securitygroups = securitygroups or io.get_input( prompts['vpc.securitygroups']) if database: dbsubnets = dbsubnets or io.get_input(prompts['vpc.dbsubnets']) if vpc_id or vpc: vpc_object = dict() vpc_object['id'] = vpc_id vpc_object['ec2subnets'] = ec2subnets if (not tier or tier.is_webserver()) and not single: vpc_object['elbsubnets'] = elbsubnets vpc_object['elbscheme'] = 'public' if elbpublic else 'internal' else: vpc_object['elbsubnets'] = None vpc_object['elbscheme'] = None if not tier or tier.is_webserver(): vpc_object['publicip'] = 'true' if publicip else 'false' else: vpc_object['publicip'] = None vpc_object['securitygroups'] = securitygroups vpc_object['dbsubnets'] = dbsubnets return vpc_object else: return {}
def form_database_object(self): create_db = self.app.pargs.database username = self.app.pargs.db_user password = self.app.pargs.db_pass engine = self.app.pargs.db_engine size = self.app.pargs.db_size instance = self.app.pargs.db_instance version = self.app.pargs.db_version if create_db or username or password or engine or size \ or instance or version: db_object = dict() if not username: io.echo() username = io.get_input(prompts['rds.username'], default='ebroot') if not password: password = io.get_pass(prompts['rds.password']) db_object['username'] = username db_object['password'] = password db_object['engine'] = engine db_object['size'] = str(size) if size else None db_object['instance'] = instance db_object['version'] = version return db_object else: return {}
def test_get_input__use_default(self, _get_input_mock): _get_input_mock.return_value = '' self.assertEqual( 'default customer input', io.get_input('some prompt', default='default customer input')) _get_input_mock.assert_called_once_with('some prompt')
def download_sample_app_user_choice(): """ Method accepts the user's choice of whether the sample application should be downloaded. Defaults to 'Y' when none is provided. :return: user's choice of whether the sample application should be downloaded """ return io.get_input('(Y/n)', default='y')
def prompt_for_enable_spot_request(): """ Method accepts the user's choice of whether spot requests should be enabled. Defaults to 'n' when none is provided. :return: user's choice of whether the spot request should be enabled """ return io.get_input('(y/N)', default='n')
def resolve_roles(env_request, interactive): """ Resolves instance-profile and service-role :param env_request: environment request :param interactive: boolean """ LOG.debug('Resolving roles') if ( ( not env_request.instance_profile or env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME ) and not env_request.template_name ): # Service supports no profile, however it is not good/recommended # Get the eb default profile env_request.instance_profile = commonops.create_default_instance_profile() if ( env_request.platform and env_request.platform.has_healthd_support and not env_request.service_role and not env_request.template_name ): role = get_service_role() if role is None: if interactive: io.echo() io.echo(prompts['create.servicerole.info']) input = io.get_input(prompts['create.servicerole.view'], default='') if input.strip('"').lower() == 'view': for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES: document = iam.get_managed_policy_document(policy_arn) io.echo(json.dumps(document, indent=4)) io.get_input(prompts['general.pressenter']) # Create the service role if it does not exist role = create_default_service_role() env_request.service_role = role
def resolve_roles(env_request, interactive): """ Resolves instance-profile and service-role :param env_request: environment request :param interactive: boolean """ LOG.debug('Resolving roles') if (env_request.instance_profile is None or env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME) \ and env_request.template_name is None: # Service supports no profile, however it is not good/recommended # Get the eb default profile env_request.instance_profile = commonops.create_default_instance_profile( ) if (env_request.platform is not None and env_request.platform.has_healthd_support() and # HealthD enabled (env_request.service_role is None) and (env_request.template_name is None)): role = get_service_role() if role is None: if interactive: io.echo() io.echo(prompts['create.servicerole.info']) input = io.get_input(prompts['create.servicerole.view'], default='') if input.strip('"').lower() == 'view': for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES: document = iam.get_managed_policy_document(policy_arn) io.echo(json.dumps(document, indent=4)) io.get_input(prompts['general.pressenter']) # Create the service role if it does not exist role = create_default_service_role() env_request.service_role = role