本文整理汇总了Python中template.Template.add_utility_bucket方法的典型用法代码示例。如果您正苦于以下问题:Python Template.add_utility_bucket方法的具体用法?Python Template.add_utility_bucket怎么用?Python Template.add_utility_bucket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template.Template
的用法示例。
在下文中一共展示了Template.add_utility_bucket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EnvironmentBase
# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import add_utility_bucket [as 别名]
#.........这里部分代码省略.........
Create new Template instance, set description and common parameters and load AMI cache.
"""
print '\nGenerating templates for {} stack\n'.format(self.globals['environment_name'])
# Configure Template class with S3 settings from config
Template.template_bucket_default = self.template_args.get('s3_bucket')
Template.s3_path_prefix = self.s3_prefix()
Template.stack_timeout = self.template_args.get("timeout_in_minutes")
Template.upload_acl = self.template_args.get('s3_upload_acl')
Template.include_timestamp = self.template_args.get('include_timestamp')
Template.include_templateValidationHash_output = self.template_args.get('include_templateValidationHash_output')
Template.include_dateGenerated_output = self.template_args.get('include_dateGenerated_output')
# Create the root template object
self.template = Template(self.globals.get('environment_name', 'default_template'))
self.template.description = self.template_args.get('description', 'No Description Specified')
self.template.resource_path = self._root_template_path()
ec2_key = self.config.get('template').get('ec2_key_default', 'default-key')
self.template._ec2_key = self.template.add_parameter(Parameter(
'ec2Key',
Type='String',
Default=ec2_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')
))
bucket_name = self.config.get('logging').get('s3_bucket')
self.template.add_utility_bucket(name=bucket_name)
self.template.add_log_group()
self.template.add_vpcflowlogs_role()
ami_filename = self.config['template'].get('ami_map_file')
if ami_filename:
ami_cache = res.load_yaml_file(ami_filename)
self.template.add_ami_mapping(ami_cache)
def generate_ami_cache(self):
"""
Generate ami_cache.json file from defaults
"""
ami_cache_filename = res.DEFAULT_AMI_CACHE_FILENAME + res.EXTENSIONS[0]
if os.path.isfile(ami_cache_filename):
overwrite = raw_input("%s already exists. Overwrite? (y/n) " % ami_cache_filename).lower()
print
if not overwrite == 'y':
return
with open(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" % ami_cache_filename
def to_json(self):
"""
Centralized method for outputting the root template with a timestamp identifying when it
was generated and for creating a SHA256 hash representing the template for validation purposes
Also recursively processess all child templates
"""
return self.template.to_template_json()
示例2: EnvironmentBase
# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import add_utility_bucket [as 别名]
#.........这里部分代码省略.........
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)
def to_json(self):
"""
Centralized method for managing outputting this template with a timestamp identifying when it was generated and for creating a SHA256 hash representing the template for validation purposes
"""
return self.template.to_template_json()
def add_common_params_to_child_template(self, template):
az_count = self.config['network']['az_count']
subnet_types = self.config['network']['subnet_types']
template.add_common_parameters(subnet_types, az_count)
template.add_parameter_idempotent(Parameter(
'ec2Key',
Type='String',
Default=self.config.get('template').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')))
# Called after add_child_template() has attached common parameters and some instance attributes:
# - RegionMap: Region to AMI map, allows template to be deployed in different regions without updating AMI ids
# - ec2Key: keyname to use for ssh authentication
# - vpcCidr: IP block claimed by whole VPC
# - vpcId: resource id of VPC
# - commonSecurityGroup: sg identifier for common allowed ports (22 in from VPC)
# - utilityBucket: S3 bucket name used to send logs to
# - availabilityZone[1-3]: Indexed names of AZs VPC is deployed to