本文整理汇总了Python中template.Template.load_ami_cache方法的典型用法代码示例。如果您正苦于以下问题:Python Template.load_ami_cache方法的具体用法?Python Template.load_ami_cache怎么用?Python Template.load_ami_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template.Template
的用法示例。
在下文中一共展示了Template.load_ami_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EnvironmentBase
# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import load_ami_cache [as 别名]
#.........这里部分代码省略.........
# record value of the debug variable
debug = config['global']['print_debug']
# Check the environment variables for any overrides
self._config_env_override(config, '', print_debug=debug)
# Validate and save results
self._validate_config(config)
self.config = config
# Save shortcut references to commonly referenced config sections
self.globals = self.config.get('global', {})
self.template_args = self.config.get('template', {})
# Register all stack handlers
self.stack_monitor = monitor.StackMonitor(self.globals['environment_name'])
for stack_handler in self.env_config.stack_event_handlers:
self._add_stack_event_handler(stack_handler)
# Register all deploy handlers
for deploy_handler in self.env_config.deploy_handlers:
self._add_deploy_handler(deploy_handler)
def initialize_template(self):
"""
Create new Template instance, set description and common parameters and load AMI cache.
"""
print 'Generating template for %s stack\n' % self.globals['environment_name']
self.template = Template(self.globals.get('output', 'default_template'))
self.template.description = self.template_args.get('description', 'No Description Specified')
self.init_root_template(self.template_args)
self.template.load_ami_cache()
def generate_ami_cache(self):
"""
Generate ami_cache.json file from defaults
"""
if os.path.isfile(res.DEFAULT_AMI_CACHE_FILENAME):
overwrite = raw_input("%s already exists. Overwrite? (y/n) " % res.DEFAULT_AMI_CACHE_FILENAME).lower()
print
if not overwrite == 'y':
return
with open(res.DEFAULT_AMI_CACHE_FILENAME, 'w') as f:
f.write(json.dumps(res.FACTORY_DEFAULT_AMI_CACHE, indent=4, separators=(',', ': ')))
print "Generated AMI cache file at %s\n" % res.DEFAULT_AMI_CACHE_FILENAME
def init_root_template(self, template_config):
"""
Adds common parameters for instance creation to the CloudFormation template
@param template_config [dict] collection of template-level configuration values to drive the setup of this method
"""
self.template.add_parameter_idempotent(Parameter('ec2Key',
Type='String',
Default=template_config.get('ec2_key_default', 'default-key'),
Description='Name of an existing EC2 KeyPair to enable SSH access to the instances',
AllowedPattern=res.get_str('ec2_key'),
MinLength=1,
MaxLength=255,
ConstraintDescription=res.get_str('ec2_key_message')))
self.template.add_utility_bucket(
name=template_config.get('utility_bucket'),
param_binding_map=self.manual_parameter_bindings)