def execute(self, parameter_pool): command = parameter_pool.get_value(ParameterName.Command) if parameter_pool.has(ParameterName.ApplicationName)\ and parameter_pool.has(ParameterName.EnvironmentName): app_name = parameter_pool.get_value(ParameterName.ApplicationName) env_name = parameter_pool.get_value(ParameterName.EnvironmentName) policy = rds_utils.is_rds_delete_to_snapshot(parameter_pool, app_name, env_name) local_rds_switch = parameter_pool.get_value(ParameterName.RdsEnabled) if policy is not None and not RdsDefault.del_policy_to_bool(policy): if command == CommandType.UPDATE: if local_rds_switch: pass else: prompt.result(AskConfirmationOpMessage.CommandWarning[command]) else: prompt.result(AskConfirmationOpMessage.CommandWarning[command]) if (parameter_pool.has(ParameterName.Force) \ and parameter_pool.get_value(ParameterName.Force) == ServiceDefault.ENABLED) \ or TerminalBase.ask_confirmation(AskConfirmationOpMessage.CommandConfirmation[command]): ret_result = OperationResult(self, None, None, None) return ret_result else: log.info('User cancelled command.') raise EBSCliException()
def _validate_change(self, parameter_pool, eb_client, app_name, env_name, option_settings, option_remove, template_spec): response = eb_client.validate_configuration_settings(app_name, option_settings, environment_name = env_name, option_remove = option_remove, template_specification = template_spec) warning_count = 0 error_count = 0 for message in response.result: if misc.string_equal_ignore_case(message.severity, ValidationSeverity.SeverityError): error_count = error_count + 1 else: warning_count = warning_count + 1 prompt.error(ValidationMessage.ValidateSettingError.format\ (message.severity, message.namespace, message.option_name, message.message)) if error_count > 0: log.info('Validating configuration setting failed. Abort command.') raise EBSCliException() elif warning_count > 0: if parameter_pool.get_value(ParameterName.Force) == ServiceDefault.ENABLED: pass elif not TerminalBase.ask_confirmation(UpdateEnvironmentOptionSettingOpMessage.Continue): log.info('User cancelled command.') raise EBSCliException() else: log.info('Validating configuration setting passed.')
def check_app_version(parameter_pool, eb_client = None): #TODO: Do we need to blast version info away if this part is strong enough? if not parameter_pool.has(PName.ApplicationVersionName) \ or parameter_pool.get_source(PName.ApplicationVersionName) == PSource.Default: version_name = get_head_version(parameter_pool, eb_client=eb_client, quiet=True) if version_name is not None: log.info(u'Found a version from local repository: {0}. Using this version.'.\ format(version_name)) return version_name else: # Otherwise try push a new one if not parameter_pool.get_value(PName.Force) == ServiceDefault.ENABLED\ and not TerminalBase.ask_confirmation(DevToolsMessage.PushLocalHead): return ServiceDefault.DEFAULT_VERSION_NAME else: if shell_utils.git_aws_push(False): version_name = get_head_version(parameter_pool, eb_client=eb_client, quiet=False) if version_name: return version_name return ServiceDefault.DEFAULT_VERSION_NAME else: # Verify existence of version app_name = parameter_pool.get_value(PName.ApplicationName, False) version_names = api_wrapper.get_all_versions(parameter_pool, app_name, eb_client) version_name = parameter_pool.get_value(PName.ApplicationVersionName) if version_name in version_names: # Assume version is still valid and compatible with current solution stack return version_name else: # return ServiceDefault.DEFAULT_VERSION_NAME
def check_app_version(parameter_pool, eb_client = None): #TODO: Do we need to blast version info away if this part is strong enough? if not parameter_pool.has(PName.ApplicationVersionName) \ or parameter_pool.get_source(PName.ApplicationVersionName) == PSource.Default: version_name = get_head_version(parameter_pool, eb_client=eb_client, quiet=True) if version_name is not None: log.info(u'Found a version from local repository: {0}. Using this version.'.\ format(version_name)) return version_name else: # Otherwise try push a new one if not parameter_pool.get_value(PName.Force) == ServiceDefault.ENABLED\ and not TerminalBase.ask_confirmation(DevToolsMessage.PushLocalHead): return ServiceDefault.DEFAULT_VERSION_NAME else: if shell_utils.git_aws_push(push_only=True, quiet=False): version_name = get_head_version(parameter_pool, eb_client=eb_client, quiet=False) if version_name: return version_name return ServiceDefault.DEFAULT_VERSION_NAME else: # Verify existence of version app_name = parameter_pool.get_value(PName.ApplicationName, False) version_names = api_wrapper.get_all_versions(parameter_pool, app_name, eb_client) version_name = parameter_pool.get_value(PName.ApplicationVersionName) if version_name in version_names: # Assume version is still valid and compatible with current solution stack return version_name else: # return ServiceDefault.DEFAULT_VERSION_NAME
def ask_parameters(self, parameter_pool, parameter_names, skip_exist): ''' Ask customer input of specified parameters via terminal interface. if skip_exist is set to True, then any parameters having value in pool will be skipped. ''' # Sort parameter list sorted_list = self._sort_list(parameter_names, parameter_pool) \ if skip_exist else self._sort_list(parameter_names, None) for parameter_name in sorted_list: if parameter_pool.has(parameter_name) and skip_exist: continue if parameter_name in self._handlers: self._handlers[parameter_name](parameter_pool) else: TerminalBase.ask_parameter(parameter_pool, parameter_name)
def execute(self, parameter_pool): command = parameter_pool.get_value(PName.Command, False) self._probe_rds_change(parameter_pool, command) if parameter_pool.get_value(PName.Force) == ServiceDefault.ENABLED \ or TerminalBase.ask_confirmation(AskConfirmationOpMessage.CommandConfirmation[command]): ret_result = OperationResult(self, None, None, None) return ret_result else: log.info(u'User cancelled command.') raise EBSCliException()