本文整理汇总了Python中troposphere.Template类的典型用法代码示例。如果您正苦于以下问题:Python Template类的具体用法?Python Template怎么用?Python Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: generate_cf
def generate_cf(self):
"""
Create Cloud Formation Template from user supplied or default config file
:return json string
"""
## read machine list from the config file ##
machines = self._readConfig(self.configdata)
if 'error' in machines:
return machines
template = Template()
template.add_description(
"%s: [%s]" % (self.owner,", ".join(self.machinelist))
)
## convert the params into cloud formation instance object ##
for subnet in machines:
for mclass in machines[subnet]:
machine = machines[subnet][mclass]
instance = self._set_instance_value(machine,mclass,self.subnet[subnet])
template.add_resource(instance)
intrecordset = self._set_internal_resource_record(mclass)
template.add_resource(intrecordset)
if subnet == 'public':
pubrecordset = self._set_public_resource_record(mclass)
template.add_resource(pubrecordset)
## this magic function turn it to jason formatted template ##
return template.to_json(),self.envname
开发者ID:fariqizwan,项目名称:aws-boto-example,代码行数:27,代码来源:cfgenerator.py
示例2: CloudFormationTemplate
class CloudFormationTemplate(CloudTemplate):
def __init__(self):
# initialize Process
super(CloudTemplate, self).__init__()
def generate(self):
self.template = Template()
for instance in self.source['instance_groups']:
image_id = instance['image_id']
instance_type = instance['type']
key_pair = instance['key_pair']
name = instance['name']
ec2_instance = self.template.add_resource(ec2.Instance(
"Ec2Instance",
ImageId=image_id,
InstanceType=instance_type,
KeyName=key_pair,
SecurityGroups=[name],
UserData=Base64("80")
))
self.template.add_output([
Output(
"InstanceId",
Description="InstanceId of the newly created EC2 instance",
Value=Ref(ec2_instance),
),
Output(
"AZ",
Description="Availability Zone of the newly created EC2 instance",
Value=GetAtt(ec2_instance, "AvailabilityZone"),
),
Output(
"PublicIP",
Description="Public IP address of the newly created EC2 instance",
Value=GetAtt(ec2_instance, "PublicIp"),
),
Output(
"PrivateIP",
Description="Private IP address of the newly created EC2 instance",
Value=GetAtt(ec2_instance, "PrivateIp"),
),
Output(
"PublicDNS",
Description="Public DNSName of the newly created EC2 instance",
Value=GetAtt(ec2_instance, "PublicDnsName"),
),
Output(
"PrivateDNS",
Description="Private DNSName of the newly created EC2 instance",
Value=GetAtt(ec2_instance, "PrivateDnsName"),
),
])
self.template = self.template.to_json()
return self.template
开发者ID:magreiner,项目名称:orchestration-tools,代码行数:60,代码来源:template.py
示例3: main
def main():
template = Template()
lambda_config = LambdaConfig(
lambda_s3_bucket='smallest-bucket-in-history',
lambda_s3_key='test_lambda.zip',
lambda_description='test function',
lambda_function_name='test_lambda',
lambda_handler='test_lambda.lambda_handler',
lambda_memory_size=128,
lambda_role_arn='arn:aws:iam::123456789:role/lambda_basic_vpc_execution_with_s3',
lambda_runtime='python2.7',
lambda_timeout=1,
lambda_schedule='rate(5 minutes)'
)
# Test Lambda
LambdaLeaf(leaf_title='MyLambda',
template=template,
dependencies=['app1:80'],
lambda_config=lambda_config,
availability_zones=['ap-southeast-2a', 'ap-southeast-2b', 'ap-southeast-2c'],
public_cidr={'name': 'PublicIp', 'cidr': '0.0.0.0/0'},
tree_name='tree'
)
print(template.to_json(indent=2, separators=(',', ': ')))
开发者ID:GeoscienceAustralia,项目名称:amazonia,代码行数:27,代码来源:test_sys_lambda_leaf.py
示例4: test_simple_table
def test_simple_table(self):
serverless_table = SimpleTable(
"SomeTable"
)
t = Template()
t.add_resource(serverless_table)
t.to_json()
开发者ID:cigan1,项目名称:troposphere,代码行数:7,代码来源:test_serverless.py
示例5: _template_init
def _template_init(self):
t = Template()
t.add_version("2010-09-09")
#t.add_parameter(Parameter("StackName",
# Description="Name of this stack",
# Type="String",))
return t
开发者ID:TrendMicroDCS,项目名称:omelet,代码行数:7,代码来源:resource.py
示例6: main
def main():
template = Template()
database_config = DatabaseConfig(
db_instance_type='db.t2.micro',
db_engine='postgres',
db_port='5432',
db_name='myDb',
db_hdd_size='5',
db_snapshot_id=None,
db_backup_window=None,
db_backup_retention=None,
db_maintenance_window=None,
db_storage_type='gp2',
owner='[email protected]'
)
DatabaseLeaf(leaf_title='MyDb',
tree_name='tree',
template=template,
database_config=database_config,
availability_zones=['ap-southeast-2a', 'ap-southeast-2b', 'ap-southeast-2c']
)
print(template.to_json(indent=2, separators=(',', ': ')))
开发者ID:GeoscienceAustralia,项目名称:amazonia,代码行数:25,代码来源:test_sys_database_leaf.py
示例7: test_mutualexclusion
def test_mutualexclusion(self):
t = Template()
t.add_resource(FakeAWSObject(
'fake', callcorrect=True, singlelist=[10])
)
with self.assertRaises(ValueError):
t.to_json()
开发者ID:gscalise,项目名称:troposphere,代码行数:7,代码来源:test_basic.py
示例8: test_s3_filter
def test_s3_filter(self):
t = Template()
t.add_resource(
Function(
"ProcessorFunction",
Handler='process_file.handler',
CodeUri='.',
Runtime='python3.6',
Policies='AmazonS3FullAccess',
Events={
'FileUpload': S3Event(
'FileUpload',
Bucket="bucket",
Events=['s3:ObjectCreated:*'],
Filter=Filter(S3Key=S3Key(
Rules=[
Rules(Name="prefix", Value="upload/"),
Rules(Name="suffix", Value=".txt"),
],
))
)
}
)
)
t.to_json()
开发者ID:cigan1,项目名称:troposphere,代码行数:25,代码来源:test_serverless.py
示例9: to_cloudformation_template
def to_cloudformation_template(self):
t = Template()
t.description = self.description
for d in self.dollops:
d.to_cloudformation_template(t)
return t
开发者ID:smithclay,项目名称:dollop,代码行数:7,代码来源:__init__.py
示例10: test_add_or_get_returns_with_out_adding_duplicate
def test_add_or_get_returns_with_out_adding_duplicate(self):
t = Template()
p = Parameter("param", Type="String", Default="foo")
t.add_parameter(p)
result = t.get_or_add_parameter(p)
self.assertEquals(t.parameters["param"], p)
self.assertEquals(result, p)
self.assertEquals(len(t.parameters), 1)
开发者ID:Arvoreen,项目名称:troposphere,代码行数:8,代码来源:test_basic.py
示例11: test_no_required
def test_no_required(self):
stack = Stack(
"mystack",
)
t = Template()
t.add_resource(stack)
with self.assertRaises(ValueError):
t.to_json()
开发者ID:3dsorcery,项目名称:troposphere,代码行数:8,代码来源:test_opsworks.py
示例12: test_s3_bucket_accelerate_configuration
def test_s3_bucket_accelerate_configuration(self):
t = Template()
ac = AccelerateConfiguration(AccelerationStatus="Enabled")
b = Bucket("s3Bucket", AccelerateConfiguration=ac)
t.add_resource(b)
output = t.to_json()
self.assertIn('"AccelerationStatus": "Enabled"', output)
开发者ID:Arvoreen,项目名称:troposphere,代码行数:8,代码来源:test_s3.py
示例13: test_api_no_definition
def test_api_no_definition(self):
serverless_api = Api(
"SomeApi",
StageName='test',
)
t = Template()
t.add_resource(serverless_api)
t.to_json()
开发者ID:cloudtools,项目名称:troposphere,代码行数:8,代码来源:test_serverless.py
示例14: create_services
def create_services(name='services', sns_name='cfSns', sqs_name='cfSqs'):
t = Template()
t.add_description("""\
microservices stack""")
create_sns_sqs(t, sns_name + name, sqs_name + name)
return t
开发者ID:amiryesh,项目名称:microservices,代码行数:8,代码来源:services.py
示例15: main
def main():
"""
Creates a troposphere template and then adds a single s3 bucket and assocaited cloud trail
"""
template = Template()
Cloudtrail('MyCloud', template)
print(template.to_json(indent=2, separators=(',', ': ')))
开发者ID:GeoscienceAustralia,项目名称:amazonia,代码行数:9,代码来源:test_sys_cloudtrail.py
示例16: test_required_api_definitionuri
def test_required_api_definitionuri(self):
serverless_api = Api(
"SomeApi",
StageName='test',
DefinitionUri='s3://bucket/swagger.yml',
)
t = Template()
t.add_resource(serverless_api)
t.to_json()
开发者ID:cigan1,项目名称:troposphere,代码行数:9,代码来源:test_serverless.py
示例17: test_required_api_definitionbody
def test_required_api_definitionbody(self):
serverless_api = Api(
"SomeApi",
StageName='test',
DefinitionBody=self.swagger,
)
t = Template()
t.add_resource(serverless_api)
t.to_json()
开发者ID:cigan1,项目名称:troposphere,代码行数:9,代码来源:test_serverless.py
示例18: __init__
def __init__(self):
TropoTemplate.__init__(self)
self.ordered_resources = OrderedDict()
self.metadata = OrderedDict()
self.conditions = OrderedDict()
self.mappings = OrderedDict()
self.outputs = OrderedDict()
self.parameters = OrderedDict()
self.resources = OrderedDict()
开发者ID:adragomir,项目名称:tropopause,代码行数:9,代码来源:__init__.py
示例19: test_ne
def test_ne(self):
t1 = Template(Description='foo1', Metadata='bar1')
t1.add_resource(Bucket('Baz1'))
t1.add_output(Output('qux1', Value='qux1'))
t2 = Template(Description='foo2', Metadata='bar2')
t2.add_resource(Bucket('Baz2'))
t2.add_output(Output('qux2', Value='qux2'))
self.assertNotEqual(t1, t2)
开发者ID:Arvoreen,项目名称:troposphere,代码行数:10,代码来源:test_template.py
示例20: test_required
def test_required(self):
stack = Stack(
"mystack",
DefaultInstanceProfileArn="instancearn",
Name="myopsworksname",
ServiceRoleArn="arn",
)
t = Template()
t.add_resource(stack)
t.to_json()
开发者ID:3dsorcery,项目名称:troposphere,代码行数:10,代码来源:test_opsworks.py
注:本文中的troposphere.Template类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论