当前位置: 首页>>代码示例>>Python>>正文


Python Template.add_description方法代码示例

本文整理汇总了Python中troposphere.Template.add_description方法的典型用法代码示例。如果您正苦于以下问题:Python Template.add_description方法的具体用法?Python Template.add_description怎么用?Python Template.add_description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在troposphere.Template的用法示例。


在下文中一共展示了Template.add_description方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_cf

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
	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,代码行数:29,代码来源:cfgenerator.py

示例2: create_services

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
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,代码行数:10,代码来源:services.py

示例3: _generate_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def _generate_template(tms=1, within_vpc=False):
    t = Template()

    t.add_description(FLINK_TEMPLATE_DESCRIPTION)
    t.add_version(FLINK_TEMPLATE_VERSION)
    t.add_metadata({'LastUpdated': datetime.datetime.now().strftime('%c')})

    # mappings
    mappings.add_mappings(t)

    # parameters
    parameters.add_parameters(t)

    vpc = None
    subnet_pri = None
    subnet_pub = None
    if within_vpc:
        # networking resources
        vpc, subnet_pri, subnet_pub = _define_vpc(t)

    # security groups
    sg_ssh = t.add_resource(securitygroups.ssh(
        parameters.ssh_location, vpc))

    sg_jobmanager = t.add_resource(securitygroups.jobmanager(
        parameters.http_location, vpc))

    sg_taskmanager = t.add_resource(securitygroups.taskmanager(None, vpc))

    jobmanager = t.add_resource(instances.jobmanager(
        0,
        [Ref(sg_ssh), Ref(sg_jobmanager)],
        within_vpc,
        subnet_pub
    ))

    prefix = "JobManager00"
    t.add_output(outputs.ssh_to(jobmanager, prefix))
    t.add_output(Output(
        "FlinkWebGui",
        Description="Flink web interface",
        Value=Join("", [
            'http://', GetAtt(jobmanager, "PublicDnsName"), ':8081'
        ])
    ))

    for index in range(0, tms):
        i = t.add_resource(instances.taskmanager(
            index,
            jobmanager,
            [Ref(sg_ssh), Ref(sg_taskmanager)],
            within_vpc,
            subnet_pri
        ))
        prefix = "TaskManager%2.2d" % index
        t.add_output(outputs.ssh_to(i, prefix, bastion=jobmanager))

    return t.to_json()
开发者ID:psmiraglia,项目名称:cloudformation-flink,代码行数:60,代码来源:templates.py

示例4: test_s3_bucket

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
 def test_s3_bucket(self):
     t = Template()
     t.add_description("S3 Bucket Example")
     s3bucket = t.add_resource(s3.Bucket(
         "S3Bucket", AccessControl=s3.PublicRead,))
     t.add_output(Output(
         "BucketName",
         Value=Ref(s3bucket),
         Description="Name of S3 bucket to hold website content"
     ))
     self.assertEqual(s3_bucket_yaml, t.to_yaml())
开发者ID:bwhaley,项目名称:troposphere,代码行数:13,代码来源:test_yaml.py

示例5: generate_json

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def generate_json():
    r = {}
    t = Template()
    # t.add_description(Join('', ["DOMjudge Cluster - ", Ref('AWS::StackName')]))
    t.add_description("DOMjudge Cluster")

    r['notify_topic'] = Select(0, Ref("AWS::NotificationARNs"))

    t.add_mapping('SizeMap', {
        'nano': {
            'RDSInstanceType': 'db.t2.micro',
            'WebInstanceType': 't2.micro',
            'WebASGMinSize': 1,
            'WebASGMaxSize': 4,
            'JudgeASGMinSize': 1,
            'JudgeASGMaxSize': 4,
        },
        'small': {
            'RDSInstanceType': 'db.t2.micro',
            'WebInstanceType': 't2.micro',
            'WebASGMinSize': 1,
            'WebASGMaxSize': 4,
            'JudgeASGMinSize': 1,
            'JudgeASGMaxSize': 4,
        },
        'medium': {
            'RDSInstanceType': 'db.t2.micro',
            'WebInstanceType': 't2.micro',
            'WebASGMinSize': 1,
            'WebASGMaxSize': 4,
            'JudgeASGMinSize': 1,
            'JudgeASGMaxSize': 4,
        },
        'large': {
            'RDSInstanceType': 'db.t2.micro',
            'WebInstanceType': 't2.micro',
            'WebASGMinSize': 1,
            'WebASGMaxSize': 4,
            'JudgeASGMinSize': 1,
            'JudgeASGMaxSize': 4,
        },
    })

    parameters.init(t, r)
    dynamodb.init(t, r)
    iam.init(t, r)
    securitygroups.init(t, r)
    rds.init(t, r)
    webserver.init(t, r)
    judgehost.init(t, r)

    return t.to_json()
开发者ID:cloudcontest,项目名称:dj_cfn_generator,代码行数:54,代码来源:__init__.py

示例6: generate_env_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def generate_env_template(app_env, env_dict):
    sg_name = env_dict['sg_name']
    vpc_id = 'vpc-a1d187c4'  # query for this!
    logger.debug('generating template for %s' % vpc_id)
    
    t = Template()
    t.add_version('2010-09-09')
    t.add_description('env template for %s' % app_env)
    app_sg = SecurityGroup('TestAppSecurityGroup')
    app_sg.VpcId = vpc_id
    app_sg.GroupDescription = 'testing'
    app_sg.Tags = name_tag(sg_name)
    t.add_resource(app_sg)
    return t.to_json()
开发者ID:matthewbga,项目名称:blargotron,代码行数:16,代码来源:generator.py

示例7: generate_application_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def generate_application_template(app_dict):
    app_name = app_dict['app_name']

    t = Template()
    t.add_version()
    t.add_description('app template for %s' % app_name)

    app = Application(app_name, Description=app_name)
    t.add_resource(app)

    bucket_name = 'ehi-pcf-%s' % app_name
    bucket = Bucket('AppBucket', BucketName=bucket_name, AccessControl=Private)
    t.add_resource(bucket)

    return t.to_json()
开发者ID:matthewbga,项目名称:blargotron,代码行数:17,代码来源:generator.py

示例8: lambda_handler

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def lambda_handler(event, context):
        #print("Received event: " + json.dumps(event, indent=2))

        # Get the object from the event and show its content type
        bucket = event['Records'][0]['s3']['bucket']['name']
        key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')
        print ("buket:" + bucket)
        print ("key:" + key)
        obj = s3.Object(bucket,key)
        response= obj.get()
        body = response['Body'].read()
        body_list= body.splitlines()
        # VPC関係
        VPC_CidrBlockList = body_list[0].split(',')
        VPC_EnableDnsSupportList = body_list[1].split(',')
        VPC_TagsValueList =  body_list[2].split(',')

        t = Template()
        t.add_version("2010-09-09")
        t.add_description("ROOP&ROOP")
        if len(VPC_CidrBlockList) > 1:
            for (address,dns,value) in zip(VPC_CidrBlockList[1:],VPC_EnableDnsSupportList[1:],VPC_TagsValueList[1:]):
                t.add_resource(VPC(
                              value,
                              EnableDnsSupport="true",
                              CidrBlock=address,
                              EnableDnsHostnames=dns,
                              Tags=Tags(Name=value)

                ))
        json_template = t.to_json()
        bucket = s3.Bucket('cf-templates-hokan')
        obj = bucket.Object('json-template-' + basename + ' .txt')
        response = obj.put(
                       Body=json_template.encode('utf-8'),
                       ContentEncoding='utf-8',
                       ContentType='text/plane'
                    )
        print(json_template)
开发者ID:tto0408,项目名称:Hello-world,代码行数:41,代码来源:test.py

示例9: add_resources

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
    def add_resources(self, resources, config):
        """
        Creates JSON-formatted string representation of stack resourcs
        suitable for use with AWS Cloudformation

        :param resources: Internal data structure of resources
        :type resources: dict.
        :param config: Config key/value pairs
        :type config: dict.
        :returns: string
        :raises: :class:`pmcf.exceptions.ProvisionerException`
        """

        LOG.info('Start building template')
        data = Template()
        desc = "%s %s stack" % (config['name'], config['environment'])
        data.add_description(desc)
        data.add_version()

        self._add_streams(data, resources.get('stream', []), config)
        self._add_queues(data, resources.get('queue', []), config)
        self._add_nets(data, resources.get('network', []), config)
        sgs = self._add_secgroups(data, resources['secgroup'], config)
        self._add_caches(data, resources.get('cache', []), config, sgs)
        lbs = self._add_lbs(data,
                            resources['load_balancer'],
                            config,
                            sgs,
                            resources['instance'])
        self._add_instances(data,
                            resources['instance'],
                            config,
                            sgs,
                            lbs)

        LOG.info('Finished building template')
        return data.to_json(indent=None)
开发者ID:pikselpalette,项目名称:pmcf,代码行数:39,代码来源:json_output.py

示例10: GenerateGlobalLayer

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
def GenerateGlobalLayer():
    t = Template()

    t.add_description("""\
    Global Layer
    """)

    stackname_param = t.add_parameter(Parameter(
        "StackName",
        Description="Environment Name (default: StepGlobals)",
        Type="String",
        Default="StepGlobals",
    ))

    crontab_table = t.add_resource(dynamodb.Table(
        "scheduleTable",
        AttributeDefinitions=[
            dynamodb.AttributeDefinition("taskname", "S"),
        ],
        KeySchema=[
            dynamodb.Key("taskname", "HASH")
        ],
        ProvisionedThroughput=dynamodb.ProvisionedThroughput(
            1,
            1
        )
    ))

    t.add_output([
        Output(
            "crontabtablename",
            Description="Crontab Table Name",
            Value=Ref(crontab_table),
        )
    ])

    return t
开发者ID:write2munish,项目名称:MiddlewareHackathon,代码行数:39,代码来源:step-globals.py

示例11: Template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
# Python script to generate the cloudformation template json file
# This is not strictly needed, but it takes the pain out of writing a
# cloudformation template by hand.  It also allows for DRY approaches
# to maintaining cloudformation templates.

from troposphere import Ref, Template, Parameter, Output, Join, GetAtt, Tags
import troposphere.ec2 as ec2

t = Template()

t.add_description(
    'An Ec2-classic stack with Couchbase Server, Sync Gateway + load testing tools '
)

NUM_COUCHBASE_SERVERS=3
NUM_SYNC_GW_SERVERS=1
NUM_GATELOADS=1

COUCHBASE_INSTANCE_TYPE="m3.medium"
SYNC_GW_INSTANCE_TYPE="m3.medium"
GATELOAD_INSTANCE_TYPE="m3.medium"

def createCouchbaseSecurityGroups(t):

    # Couchbase security group
    secGrpCouchbase = ec2.SecurityGroup('CouchbaseSecurityGroup')
    secGrpCouchbase.GroupDescription = "Allow access to Couchbase Server"
    secGrpCouchbase.SecurityGroupIngress = [
        ec2.SecurityGroupRule(
            IpProtocol="tcp",
开发者ID:linearregression,项目名称:perfcluster-aws,代码行数:32,代码来源:cloudformation_template.py

示例12: Template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
from troposphere import Template, Parameter, Ref, Tags, Output, GetAtt, ec2

import template_utils as utils
import troposphere.autoscaling as asg
import troposphere.cloudwatch as cw
import troposphere.elasticloadbalancing as elb

t = Template()

t.add_version('2010-09-09')
t.add_description('An application server stack for the nyc-trees project.')

#
# Parameters
#
color_param = t.add_parameter(Parameter(
    'StackColor', Type='String',
    Description='Stack color', AllowedValues=['Blue', 'Green'],
    ConstraintDescription='must be either Blue or Green'
))

vpc_param = t.add_parameter(Parameter(
    'VpcId', Type='String', Description='Name of an existing VPC'
))

keyname_param = t.add_parameter(Parameter(
    'KeyName', Type='String', Default='nyc-trees-stg',
    Description='Name of an existing EC2 key pair'
))

notification_arn_param = t.add_parameter(Parameter(
开发者ID:strk,项目名称:nyc-trees,代码行数:33,代码来源:app_template.py

示例13: Template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
from troposphere.logs import MetricFilter, MetricTransformation

METRIC_NAMESPACE = "BBC/CHAOS-LAMBDA"

t = Template()

log_group = t.add_parameter(
    Parameter(
        "LambdaLogGroupName",
        Description="The name of the log group for the lambda function.",
        Type="String",
    )
)

t.add_description(
    "Metrics and filters for Chaos Lambda"
)

lambda_metrics = {
    "liveliness": {
        "FilterPattern": (
            "[datetime, event=\"triggered\", ...]"
        ),
        "MetricTransformations": [
            MetricTransformation(
                MetricNamespace=METRIC_NAMESPACE,
                MetricName="triggered",
                MetricValue="1",
            )
        ]
    }
开发者ID:bbc,项目名称:chaos-lambda,代码行数:33,代码来源:metrics.py

示例14: Template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
from troposphere import Base64, Select, FindInMap, GetAtt, GetAZs, Join, Output
from troposphere import Parameter, Ref, Tags, Template
from troposphere.cloudformation import Init
from troposphere.cloudfront import Distribution, DistributionConfig
from troposphere.cloudfront import Origin, DefaultCacheBehavior
from troposphere.ec2 import PortRange
from troposphere.iam import InstanceProfile
from troposphere.iam import Role
from troposphere.iam import Group


t = Template()

t.add_version("2010-09-09")

t.add_description("""\
IAM""")
craftInstanceProfile = t.add_resource(InstanceProfile(
    "craftInstanceProfile",
    Path="/",
    Roles=[Ref("craftIamRole")],
))

BastionInstanceProfile = t.add_resource(InstanceProfile(
    "BastionInstanceProfile",
    Path="/",
    Roles=[Ref("BastionIamRole")],
))

BastionIamRole = t.add_resource(Role(
    "BastionIamRole",
    Path="/",
开发者ID:skiermw,项目名称:tropo,代码行数:34,代码来源:IAM-cfn.py

示例15: Template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_description [as 别名]
#!/usr/bin/env python

from __future__ import print_function

from troposphere import Base64, Join, GetAtt
from troposphere import Parameter, Ref, Template
from troposphere import ec2, iam
from troposphere.autoscaling import AutoScalingGroup, Tag
from troposphere.autoscaling import LaunchConfiguration
from troposphere.route53 import RecordSet, RecordSetGroup, AliasTarget
import troposphere.elasticloadbalancing as elb


templ = Template()

templ.add_description('Kibana cloudformation template')

instance_type = templ.add_parameter(Parameter(
    'InstanceType',
    Type='String',
    Description='Instande type for instances',
    Default='m3.medium'
))

key_name = templ.add_parameter(Parameter(
    'KeyName',
    Type='AWS::EC2::KeyPair::KeyName',
    Description='Name of an existing EC2 KeyPair to enable SSH access',
))

cluster_name = templ.add_parameter(Parameter(
开发者ID:scm-spain,项目名称:elk-stack,代码行数:33,代码来源:kibana-cfn.py


注:本文中的troposphere.Template.add_description方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。