def execute(self, parameter_pool): eb_client = self._get_eb_client(parameter_pool) app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) version_name = eb_utils.check_app_version(parameter_pool, eb_client) env_name = parameter_pool.get_value(ParameterName.EnvironmentName, False) stack_name = parameter_pool.get_value(ParameterName.SolutionStack, False) tier = parameter_pool.get_value(ParameterName.EnvironmentTier, False) spec = TemplateSpecification() # Try load option setting file if exist option_location = parameter_pool.get_value(ParameterName.OptionSettingFile, False) option_settings = config_file.load_env_option_setting_file(option_location, quiet = True) if option_settings is not None and len(option_settings) > 0: prompt.info(CreateEnvironmentOpMessage.UsingOptionSetting.format(option_location)) else: option_settings = dict() option_remove = dict() # Process extensions first before we process options self._extension_handler(parameter_pool, spec, stack_name, option_settings, option_remove) # Process options self._option_setting_handler(parameter_pool, spec, stack_name, None, 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, tier = tier) 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 = self._get_eb_client(parameter_pool) app_name = parameter_pool.get_value(ParameterName.ApplicationName, False) version_name = eb_utils.check_app_version(parameter_pool, eb_client) env_name = parameter_pool.get_value(ParameterName.EnvironmentName, False) stack_name = parameter_pool.get_value(ParameterName.SolutionStack, False) spec = TemplateSpecification() # Try load option setting file if exist option_location = parameter_pool.get_value(ParameterName.OptionSettingFile, False) option_settings = config_file.load_env_option_setting_file(option_location, quiet = True) if option_settings is not None and len(option_settings) > 0: prompt.info(CreateEnvironmentOpMessage.UsingOptionSetting.format(option_location)) else: option_settings = dict() option_remove = dict() self._option_setting_handler(parameter_pool, spec, stack_name, 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('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('Received response for CreateEnvironemnt call.') prompt.info(CreateEnvironmentOpMessage.Succeed) prompt.result(CreateEnvironmentOpMessage.WaitAfterLaunch.format(env_name)) self._log_api_result(self.__class__.__name__, '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