本文整理汇总了Python中scli.constants.RdsDefault类的典型用法代码示例。如果您正苦于以下问题:Python RdsDefault类的具体用法?Python RdsDefault怎么用?Python RdsDefault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RdsDefault类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
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()
示例2: generate_endpoint
def generate_endpoint(parameter_pool, region, source, force = False):
parameter_pool.put(Parameter(ParameterName.RdsEndpoint,
RdsEndpoint[region],
source))
parameter_pool.put(Parameter(ParameterName.RdsSnippetUrl,
RdsDefault.get_snippet_url(region),
source))
示例3: execute
def execute(self, parameter_pool):
location = EbLocalDir.Path + os.path.sep + EbConfigFile.Name
try:
config_file.load_eb_config_file(location, parameter_pool, False)
if config_file.check_access_permission(location) is False:
message = ConfigFileErrorMessage.PermissionError.format(EbConfigFile.Name)
log.info(message)
prompt.error(message)
#Post processing
if not parameter_pool.has(ParameterName.RdsSnippetUrl)\
and parameter_pool.has(ParameterName.Region):
region = parameter_pool.get_value(ParameterName.Region)
parameter_pool.put(Parameter(ParameterName.RdsSnippetUrl,
RdsDefault.get_snippet_url(region),
ParameterSource.ConfigFile))
except EBConfigFileNotExistError:
log.error('Configuration file "{0}" not exist.'.format(EbConfigFile.Name))
prompt.error(ConfigFileMessage.CannotFind.format\
(EbConfigFile.Name, CommandType.INIT.lower()))
raise EBSCliException()
except BaseException as ex:
log.error('Encountered error when load configuration file "{0}", becuase "{1}".'.\
format(EbConfigFile.Name, ex))
prompt.error(ConfigFileMessage.CorrectionSuggestion.
format(location,CommandType.INIT.lower()))
raise
ret_result = OperationResult(self, None, None, None)
return ret_result
示例4: _add_rds_extension
def _add_rds_extension(parameter_pool, option_settings, option_to_remove):
region = parameter_pool.get_value(ParameterName.Region)
#Generate snippet
env_name = parameter_pool.get_value(ParameterName.EnvironmentName)
if has_rds_instance(parameter_pool, env_name):
spec = None
else:
spec = TemplateSpecification()
snippet = TemplateSnippet()
snippet.snippet_name = RdsDefault.SnippetName
snippet.source_url = RdsDefault.get_snippet_url(region)
snippet.order = RdsDefault.SnippetAddOrder
spec.template_snippets = [snippet]
#Add/update option settings
#TODO: change option_settings to o(1) structure while retain order for output
for pname in RdsDefault.OptionMinSet:
if parameter_pool.has(pname) and parameter_pool.get_value(pname) is not None:
_update_option_setting(option_settings,
RdsDefault.Namespace,
RdsDefault.OptionNames[pname],
parameter_pool.get_value(pname))
_trim_rds_options(option_settings, option_to_remove)
return spec
示例5: ask_delete_to_snapshot
def ask_delete_to_snapshot(cls, parameter_pool):
if parameter_pool.has(PName.RdsDeletionPolicy):
original_value = parameter_pool.get_value(PName.RdsDeletionPolicy)
display_value = RdsDefault.del_policy_to_bool(original_value)
display_value = misc.bool_to_yesno(display_value)
else:
display_value = None
value = cls.ask_parameter(parameter_pool, PName.RdsDeletionPolicy, display_value)
if value is None:
return
elif not isinstance(value, bool):
value = RdsDefault.bool_to_del_policy(misc.string_to_boolean(value))
parameter_pool.put(Parameter(PName.RdsDeletionPolicy,
value,
PSource.Terminal),
True)
示例6: is_rds_delete_to_snapshot
def is_rds_delete_to_snapshot(parameter_pool, app_name, env_name):
policy_option = OptionSepcification(RdsDefault.Namespace,
RdsDefault.OptionNames[ParameterName.RdsDeletionPolicy])
policy_setting = api_wrapper.retrieve_configuration_settings(parameter_pool, app_name,
env_name = env_name,
options = [policy_option])
if len(policy_setting) != 1:
return None # Option name not found. No RDS instance
return RdsDefault.del_policy_to_bool(policy_setting[0].value)
示例7: _remove_rds_extension
def _remove_rds_extension(parameter_pool, template_spec, option_settings, option_to_remove):
region = parameter_pool.get_value(ParameterName.Region, False)
#Generate snippet
snippet = TemplateSnippet()
snippet.snippet_name = RdsDefault.SnippetName
snippet.source_url = RdsDefault.get_snippet_url(region)
snippet.order = RdsDefault.SnippetRemoveOrder
template_spec.template_snippets.append(snippet)
#Remove option settings
_remove_all_rds_options(option_settings, option_to_remove)
示例8: is_rds_delete_to_snapshot
def is_rds_delete_to_snapshot(parameter_pool, app_name, env_name):
policy_options = {RdsDefault.Namespace: {RdsDefault.OptionNames[ParameterName.RdsDeletionPolicy]}}
try:
policy_setting = api_wrapper.retrieve_configuration_settings(parameter_pool, app_name,
env_name = env_name,
options = policy_options)
except InvalidParameterValueException:
return None # Environment not exist. No RDS instance
if len(policy_setting) < 1:
return None # Option name not found. No RDS instance
return RdsDefault.del_policy_to_bool(policy_setting[RdsDefault.Namespace]\
[RdsDefault.OptionNames[ParameterName.RdsDeletionPolicy]])
示例9: ask_region
def ask_region(cls, parameter_pool):
original_value = parameter_pool.get_value(ParameterName.Region) \
if parameter_pool.has(ParameterName.Region) else None
original_source = parameter_pool.get_source(ParameterName.Region) \
if parameter_pool.has(ParameterName.Region) else None
if original_value is not None and \
ParameterSource.is_ahead(original_source, ParameterSource.Terminal):
print(TerminalPromptSettingParameterMessage[ParameterName.Region].\
format(ServiceRegionName[original_value]))
region_value = original_value
else:
append_message = u'' if original_value is None \
else TerminalMessage.CurrentValue.format(ServiceRegionName[original_value])
print TerminalPromptAskingMessage[ParameterName.Region].format(append_message)
region_name_list = list()
for region in AvailableServiceRegion:
region_name_list.append(ServiceRegionName[region])
region_index = cls.single_choice(region_name_list,
TerminalMessage.AvailableRegion,
None,
original_value is not None)
region_value = AvailableServiceRegion[region_index] \
if region_index is not None else original_value
region = Parameter(ParameterName.Region,
misc.to_unicode(region_value),
ParameterSource.Terminal)
parameter_pool.put(region, True)
# Set service endpoint if not specified as CLI arguments
cls._set_parameter_value(parameter_pool,
ParameterName.ServiceEndpoint,
misc.to_unicode(ServiceEndpoint[region_value]),
ParameterSource.Terminal)
# Set RDS endpont and snippet if not specified as CLI arguments
cls._set_parameter_value(parameter_pool,
ParameterName.RdsEndpoint,
RdsEndpoint[region_value],
ParameterSource.Terminal)
cls._set_parameter_value(parameter_pool,
ParameterName.RdsSnippetUrl,
RdsDefault.get_snippet_url(region_value),
ParameterSource.Terminal)
示例10: _remove_rds_extension
def _remove_rds_extension(parameter_pool, template_spec, option_settings, option_to_remove):
region = parameter_pool.get_value(ParameterName.Region)
#Generate snippet
snippet = TemplateSnippet()
snippet.snippet_name = RdsDefault.SnippetName
snippet.source_url = RdsDefault.get_snippet_url(region)
snippet.order = RdsDefault.SnippetRemoveOrder
template_spec.template_snippets.append(snippet)
#Remove option settings
for pname in RdsDefault.OptionNames:
_remove_option_setting(option_settings,
option_to_remove,
RdsDefault.Namespace,
RdsDefault.OptionNames[pname])
示例11: _probe_rds_change
def _probe_rds_change(self, parameter_pool, 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])