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


Python Template.add_output方法代码示例

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


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

示例1: sceptre_handler

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
def sceptre_handler(sceptre_user_data):

    t = Template()

    vpc = t.add_resource(VPC(
        "VirtualPrivateCloud",
        CidrBlock=sceptre_user_data["cidr_block"],
        InstanceTenancy="default",
        EnableDnsSupport=True,
        EnableDnsHostnames=True,
    ))

    igw = t.add_resource(InternetGateway(
        "InternetGateway",
    ))

    t.add_resource(VPCGatewayAttachment(
        "IGWAttachment",
        VpcId=Ref(vpc),
        InternetGatewayId=Ref(igw),
    ))

    t.add_output(Output(
        "VpcId",
        Description="New VPC ID",
        Value=Ref(vpc)
    ))

    return t.to_json()
开发者ID:TWinsnes,项目名称:sceptre,代码行数:31,代码来源:vpc_sud.py

示例2: __init__

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
class CFLab:
    '''
    Class creates VPC/Subnets/ELB/ASG for Cloudformation lab
    '''

    def __init__(self, config_dictionary):
        '''
        Method initializes the DevDeploy class and composes the CloudFormation template to deploy the solution
        @param config_dictionary [dict] collection of keyword arguments for this class implementation
        '''
        self.globals                    = config_dictionary.get('globals', {})
        self.template_args              = config_dictionary.get('template', {})

        self.template                   = Template()
        self.template.description       = self.globals.get('description', '')

        #create VPC, EC2
        self.vpc_generator = VPCGenerator(self.template_args)
        self.ec2_generator = EC2Generator(
            self.template_args,
            self.vpc_generator.vpc,
            self.vpc_generator.subnets
        )

        for resource in self.vpc_generator.resources:
            self.template.add_resource(resource)

        for resource in self.ec2_generator.resources:
            self.template.add_resource(resource)

        for output in self.ec2_generator.outputs:
            self.template.add_output(output)
开发者ID:DualSpark,项目名称:lab-cloudformation,代码行数:34,代码来源:lab.py

示例3: CloudFormationTemplate

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

示例4: test_ne

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

示例5: test_s3_bucket

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [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

示例6: test_hash

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
    def test_hash(self):
        metadata = 'foo'
        description = 'bar'
        resource = Bucket('Baz')
        output = Output('qux', Value='qux')

        t1 = Template(Description=description, Metadata=metadata)
        t1.add_resource(resource)
        t1.add_output(output)

        t2 = Template(Description=description, Metadata=metadata)
        t2.add_resource(resource)
        t2.add_output(output)

        self.assertEqual(len(set([t1, t2])), 1)
开发者ID:Arvoreen,项目名称:troposphere,代码行数:17,代码来源:test_template.py

示例7: output_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
    def output_template(self):
        template = Template()
        for parameter in self.parameters:
            template.add_parameter(parameter)

        for mapping in self.mappings:
            template.add_mapping(mapping[0], mapping[1])

        for resource in self.resources:
            template.add_resource(resource)

        for output in self.outputs:
            template.add_output(output)

        print template.to_json()
        return
开发者ID:wardavison,项目名称:CloudformationBase,代码行数:18,代码来源:stack.py

示例8: _generate_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [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

示例9: GenerateGlobalLayer

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [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

示例10: build_vpc_template

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
def build_vpc_template(vpc_config):
    vpc_tags = [{"Key": "Application", "Value": Ref("AWS::StackId")}]
    vpc = ec2.VPC(name=vpc_config["Name"],
                  CidrBlock=vpc_config["IP Range"],
                  Tags=vpc_tags)

    t = Template()

    vpc_config["Subnets"].sort(key=lambda net: net["IP Count"], reverse=True)
    subnets = build_subnets(vpc_config["Subnets"], vpc_config["IP Range"], vpc_config["Name"])
    [subnet.Tags.append(vpc.Tags[0]) for subnet in subnets]

    private_route_table = build_private_route_table(vpc_config["Name"])
    public_route_table = build_public_route_table(vpc_config["Name"])

    t.add_resource(vpc)
    t.add_resource(private_route_table)
    t.add_resource(public_route_table)
    t.add_resource(build_public_route())
    [t.add_resource(public_route_table_association)
     for public_route_table_association in build_public_route_table_associations(vpc_config["Subnets"])]

    [t.add_resource(subnet) for subnet in subnets]
    [t.add_resource(gateway_attachments) for gateway_attachments in build_public_gateway(vpc_config["Name"])]
    management_group = build_management_security_group(vpc_config["Name"])
    t.add_resource(management_group[0])
    default_group = build_default_security_group(vpc_config["Name"])
    t.add_resource(default_group[0])
    t.add_resource(default_group[1])

    t.add_output(management_group[1])
    t.add_output(default_group[2])
    t.add_output(Output(name="vpcId", Value=Ref(vpc_config["Name"])))
    [t.add_output(Output(name=subnet.name, Value=Ref(subnet.name))) for subnet in subnets]

    return t
开发者ID:RosterBot,项目名称:platform,代码行数:38,代码来源:vpc.py

示例11: main

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]

#.........这里部分代码省略.........
                                    'runas=root\n'
                                    ]),
                                # Why doesn't the Amazon template have this?
                                # mode='000400',
                                # owner='root',
                                # group='root'
                                ),
                        }),

                    commands={
                        '01-install_phpredis': {
                            'command': '/usr/local/bin/install_phpredis'
                            },
                        '02-get-cluster-config': {
                            'command': '/usr/local/bin/get_cluster_config'
                            }
                        },

                    services={
                        "sysvinit": cloudformation.InitServices({
                            "httpd": cloudformation.InitService(
                                enabled=True,
                                ensureRunning=True,
                                ),
                            "cfn-hup": cloudformation.InitService(
                                enabled=True,
                                ensureRunning=True,
                                files=['/etc/cfn/cfn-hup.conf',
                                       '/etc/cfn/hooks.d/'
                                       'cfn-auto-reloader.conf']
                                ),
                            }),
                        },
                    )
                })
            ),
        ImageId=FindInMap('AWSRegionArch2AMI', Ref('AWS::Region'),
                          FindInMap('AWSInstanceType2Arch',
                                    Ref(instancetype), 'Arch')),
        InstanceType=Ref(instancetype),
        SecurityGroups=[Ref(webserversg)],
        KeyName=Ref(keyname),
        IamInstanceProfile=Ref(webserverinstanceprofile),
        UserData=Base64(Join('', [
            '#!/bin/bash -xe\n',
            'yum update -y aws-cfn-bootstrap\n',

            '# Setup the PHP sample application\n',
            '/opt/aws/bin/cfn-init -v ',
            '         --stack ', Ref('AWS::StackName'),
            '         --resource WebServerInstance ',
            '         --region ', Ref('AWS::Region'), '\n',

            '# Signal the status of cfn-init\n',
            '/opt/aws/bin/cfn-signal -e $? ',
            '         --stack ', Ref('AWS::StackName'),
            '         --resource WebServerInstance ',
            '         --region ', Ref('AWS::Region'), '\n'
            ])),
        CreationPolicy=CreationPolicy(
            ResourceSignal=ResourceSignal(Timeout='PT15M')
            ),
        Tags=Tags(Application=Ref('AWS::StackId'),
                  Details='Created using Troposhpere')
        ))

    redisclustersg = template.add_resource(elasticache.SecurityGroup(
        'RedisClusterSecurityGroup',
        Description='Lock the cluster down',
        ))

    template.add_resource(elasticache.SecurityGroupIngress(
        'RedisClusterSecurityGroupIngress',
        CacheSecurityGroupName=Ref(redisclustersg),
        EC2SecurityGroupName=Ref(webserversg),
        ))

    template.add_resource(elasticache.CacheCluster(
        'RedisCluster',
        Engine='redis',
        CacheNodeType=Ref(cachenodetype),
        NumCacheNodes='1',
        CacheSecurityGroupNames=[Ref(redisclustersg)],
        ))

    # Outputs
    template.add_output([
        Output(
            'WebsiteURL',
            Description='Application URL',
            Value=Join('', [
                'http://',
                GetAtt(webserverinstance, 'PublicDnsName'),

                ])
            )
        ])

    # Print CloudFormation Template
    print(template.to_json())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:104,代码来源:ElastiCacheRedis.py

示例12: Output

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
    ],
))

t.add_output([
    Output(
        "AmbariURL",
        Description="URL of Ambari UI",
        Value=Join("", [
            "http://", GetAtt('AmbariNode', 'PublicDnsName'), ":8080"
        ]),
    ),
    Output(
        "AmbariSSH",
        Description="SSH to the Ambari Node",
        Value=Join("", [
            "ssh [email protected]", GetAtt('AmbariNode', 'PublicDnsName')
        ]),
    ),
    Output(
        "AmbariServiceInstanceId",
        Description="The Ambari Servers Instance-Id",
        Value=Ref('AmbariNode')
    ),
    Output(
        "Region",
        Description="AWS Region",
        Value=ref_region
    ),
])

if __name__ == '__main__':
开发者ID:uprush,项目名称:masterclass,代码行数:33,代码来源:cloudformation-existing-vpc.py

示例13: main

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]

#.........这里部分代码省略.........
        )
    )

    # Add the web server instance
    WebInstance = template.add_resource(ec2.Instance(
        "WebInstance",
        SecurityGroups=[Ref(instance_sg)],
        KeyName=Ref(keyname_param),
        InstanceType=Ref("InstanceType"),
        ImageId=FindInMap("RegionMap", Ref("AWS::Region"), "AMI"),
        UserData=Base64(Ref(webport_param)),
    ))

    # Add the api server instance
    ApiInstance = template.add_resource(ec2.Instance(
        "ApiInstance",
        SecurityGroups=[Ref(instance_sg)],
        KeyName=Ref(keyname_param),
        InstanceType=Ref("InstanceType"),
        ImageId=FindInMap("RegionMap", Ref("AWS::Region"), "AMI"),
        UserData=Base64(Ref(apiport_param)),
    ))

    # Add the application ELB
    ApplicationElasticLB = template.add_resource(elb.LoadBalancer(
        "ApplicationElasticLB",
        Name="ApplicationElasticLB",
        Scheme="internet-facing",
        Subnets=[Ref(subnetA), Ref(subnetB)]
    ))

    TargetGroupWeb = template.add_resource(elb.TargetGroup(
        "TargetGroupWeb",
        HealthCheckIntervalSeconds="30",
        HealthCheckProtocol="HTTP",
        HealthCheckTimeoutSeconds="10",
        HealthyThresholdCount="4",
        Matcher=elb.Matcher(
            HttpCode="200"),
        Name="WebTarget",
        Port=Ref(webport_param),
        Protocol="HTTP",
        Targets=[elb.TargetDescription(
            Id=Ref(WebInstance),
            Port=Ref(webport_param))],
        UnhealthyThresholdCount="3",
        VpcId=Ref(VpcId)

    ))

    TargetGroupApi = template.add_resource(elb.TargetGroup(
        "TargetGroupApi",
        HealthCheckIntervalSeconds="30",
        HealthCheckProtocol="HTTP",
        HealthCheckTimeoutSeconds="10",
        HealthyThresholdCount="4",
        Matcher=elb.Matcher(
            HttpCode="200"),
        Name="ApiTarget",
        Port=Ref(apiport_param),
        Protocol="HTTP",
        Targets=[elb.TargetDescription(
            Id=Ref(ApiInstance),
            Port=Ref(apiport_param))],
        UnhealthyThresholdCount="3",
        VpcId=Ref(VpcId)

    ))

    Listener = template.add_resource(elb.Listener(
        "Listener",
        Port="80",
        Protocol="HTTP",
        LoadBalancerArn=Ref(ApplicationElasticLB),
        DefaultActions=[elb.Action(
            Type="forward",
            TargetGroupArn=Ref(TargetGroupWeb)
        )]
    ))

    template.add_resource(elb.ListenerRule(
        "ListenerRuleApi",
        ListenerArn=Ref(Listener),
        Conditions=[elb.Condition(
            Field="path-pattern",
            Values=["/api/*"])],
        Actions=[elb.Action(
            Type="forward",
            TargetGroupArn=Ref(TargetGroupApi)
        )],
        Priority="1"
    ))

    template.add_output(Output(
        "URL",
        Description="URL of the sample website",
        Value=Join("", ["http://", GetAtt(ApplicationElasticLB, "DNSName")])
    ))

    print(template.to_json())
开发者ID:Arvoreen,项目名称:troposphere,代码行数:104,代码来源:ApplicationELB.py

示例14: Output

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
key = t.add_resource(ApiKey(
    "ApiKey",
    StageKeys=[StageKey(
        RestApiId=Ref(rest_api),
        StageName=Ref(stage)
    )]
))

# Add the deployment endpoint as an output
t.add_output([
    Output(
        "ApiEndpoint",
        Value=Join("", [
            "https://",
            Ref(rest_api),
            ".execute-api.eu-west-1.amazonaws.com/",
            stage_name
        ]),
        Description="Endpoint for this stage of the api"
    ),
    Output(
        "ApiKey",
        Value=Ref(key),
        Description="API key"
    ),
])


print(t.to_json())
开发者ID:alex-paterson,项目名称:troposphere,代码行数:31,代码来源:ApiGateway.py

示例15: Output

# 需要导入模块: from troposphere import Template [as 别名]
# 或者: from troposphere.Template import add_output [as 别名]
        ],
        EvaluationPeriods=Ref(credit_evaluations),
        Threshold=Ref(credit_threshold),
        ComparisonOperator="LessThanOrEqualToThreshold",
        AlarmActions=[],
        InsufficientDataActions=[],
        OKActions=[],
    )
)

t.add_output([
    Output(
        'UpAlarm',
        Description='Alarm name for up/high',
        Value=Ref(high_cpu_alarm)
    ),
    Output(
        'DownAlarm',
        Description='Alarm name for down/low',
        Value=Ref(low_cpu_alarm)
    ),
    Output(
        'CreditLowAlarm',
        Description='Alarm name for credits out',
        Value=Ref(low_credit_alarm)
    )
])

if __name__ == '__main__':
    print t.to_json()
开发者ID:coingraham,项目名称:ReDS,代码行数:32,代码来源:alarms.py


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