def _option_setting_handler(self, parameter_pool, template_spec, stack_name, option_settings, option_remove): rds_utils.rds_handler(parameter_pool, template_spec, stack_name, option_settings, option_remove) eb_utils.trim_vpc_options(option_settings, option_remove) iam_utils.apply_instance_profile(parameter_pool, option_settings, option_remove)
def execute(self, parameter_pool): eb_client = ElasticBeanstalkClient( parameter_pool.get_value(ParameterName.AwsAccessKeyId), parameter_pool.get_value(ParameterName.AwsSecretAccessKey), parameter_pool.get_value(ParameterName.ServiceEndpoint)) app_name = parameter_pool.get_value(ParameterName.ApplicationName) env_name = parameter_pool.get_value(ParameterName.EnvironmentName) stack_name = parameter_pool.get_value(ParameterName.SolutionStack) prompt.action( UpdateEnvironmentOptionSettingOpMessage.Start.format(env_name)) location = parameter_pool.get_value(ParameterName.OptionSettingFile) option_settings = config_file.load_env_option_setting_file(location, quiet=True) if option_settings is not None and len(option_settings) > 0: prompt.info( UpdateEnvironmentOptionSettingOpMessage.UsingOptionSetting. format(location)) else: option_settings = [] option_remove = set() spec = TemplateSpecification() rds_utils.rds_handler(parameter_pool, spec, stack_name, option_settings, option_remove) self._option_setting_handler(option_settings, option_remove) self._validate_change(parameter_pool, eb_client, app_name, env_name, option_settings, option_remove, spec) try: response = eb_client.update_environment( env_name, option_settings=option_settings, option_remove=option_remove, template_specification=spec) except: raise else: log.info('Received response for UpdateEnvironemnt call.') prompt.result( UpdateEnvironmentOptionSettingOpMessage.Succeed.format( env_name)) self._log_api_result(self.__class__.__name__, 'UpdateEnvironment', response.result) parameter_pool.put( Parameter(ParameterName.UpdateEnvironmentRequestID, response.request_id, ParameterSource.OperationOutput)) ret_result = OperationResult( self, response.request_id, UpdateEnvironmentOptionSettingOpMessage.Succeed.format( env_name), response.result) return ret_result
def execute(self, parameter_pool): eb_client = ElasticBeanstalkClient(parameter_pool.get_value(ParameterName.AwsAccessKeyId), parameter_pool.get_value(ParameterName.AwsSecretAccessKey), parameter_pool.get_value(ParameterName.ServiceEndpoint)) app_name = parameter_pool.get_value(ParameterName.ApplicationName) version_name = parameter_pool.get_value(ParameterName.ApplicationVersionName) env_name = parameter_pool.get_value(ParameterName.EnvironmentName) stack_name = parameter_pool.get_value(ParameterName.SolutionStack) # Try load option setting file if exist option_file_location = parameter_pool.get_value(ParameterName.OptionSettingFile) option_settings = config_file.load_env_option_setting_file(option_file_location, quiet = True) if option_settings is not None and len(option_settings) > 0: prompt.info(CreateEnvironmentOpMessage.UsingOptionSetting.format(option_file_location)) else: option_settings = [] option_remove = set() spec = TemplateSpecification() rds_utils.rds_handler(parameter_pool, spec, stack_name, option_settings, option_remove) self._option_setting_handler(option_settings, option_remove) prompt.action(CreateEnvironmentOpMessage.Start.format(env_name)) try: response = eb_client.create_environment(application = app_name, environment = env_name, solution_stack = stack_name, version_label = version_name, option_settings = option_settings, option_remove = option_remove, template_specification = spec, ) except AlreadyExistException: log.info(u'Environment "{0}" already exist.'.format(env_name)) prompt.result(CreateEnvironmentOpMessage.AlreadyExist.format(env_name)) ret_result = OperationResult(self, None, CreateEnvironmentOpMessage.AlreadyExist.format(env_name), None) else: log.info(u'Received response for CreateEnvironemnt call.') prompt.info(CreateEnvironmentOpMessage.Succeed) prompt.result(CreateEnvironmentOpMessage.WaitAfterLaunch.format(env_name)) self._log_api_result(self.__class__.__name__, u'CreateEnvironment', response.result) parameter_pool.put(Parameter(ParameterName.CreateEnvironmentRequestID, response.request_id, ParameterSource.OperationOutput)) ret_result = OperationResult(self, response.request_id, CreateEnvironmentOpMessage.Succeed, response.result) return ret_result
def execute(self, parameter_pool): eb_client = ElasticBeanstalkClient(parameter_pool.get_value(ParameterName.AwsAccessKeyId), parameter_pool.get_value(ParameterName.AwsSecretAccessKey), parameter_pool.get_value(ParameterName.ServiceEndpoint)) app_name = parameter_pool.get_value(ParameterName.ApplicationName) env_name = parameter_pool.get_value(ParameterName.EnvironmentName) stack_name = parameter_pool.get_value(ParameterName.SolutionStack) prompt.action(UpdateEnvironmentOptionSettingOpMessage.Start.format(env_name)) location = parameter_pool.get_value(ParameterName.OptionSettingFile) option_settings = config_file.load_env_option_setting_file(location, quiet = True) if option_settings is not None and len(option_settings) > 0: prompt.info(UpdateEnvironmentOptionSettingOpMessage.UsingOptionSetting.format(location)) else: option_settings = [] option_remove = set() spec = TemplateSpecification() rds_utils.rds_handler(parameter_pool, spec, stack_name, option_settings, option_remove) self._option_setting_handler(option_settings, option_remove) self._validate_change(parameter_pool, eb_client, app_name, env_name, option_settings, option_remove, spec) try: response = eb_client.update_environment(env_name, option_settings = option_settings, option_remove = option_remove, template_specification = spec) except: raise else: log.info(u'Received response for UpdateEnvironemnt call.') prompt.result(UpdateEnvironmentOptionSettingOpMessage.Succeed.format(env_name)) self._log_api_result(self.__class__.__name__, u'UpdateEnvironment', response.result) parameter_pool.put(Parameter(ParameterName.UpdateEnvironmentRequestID, response.request_id, ParameterSource.OperationOutput)) ret_result = OperationResult(self, response.request_id, UpdateEnvironmentOptionSettingOpMessage.Succeed.format(env_name), response.result) return ret_result
def _option_setting_handler(self, parameter_pool, template_spec, stack_name, option_settings, option_remove): rds_utils.rds_handler(parameter_pool, template_spec, stack_name, option_settings, option_remove) eb_utils.apply_environment_type(parameter_pool, stack_name, option_settings, option_remove) eb_utils.trim_vpc_options(option_settings, option_remove) iam_utils.apply_instance_profile(parameter_pool, option_settings, option_remove)