• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang cloudformer.CloudFormer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vito/cloudformer.CloudFormer的典型用法代码示例。如果您正苦于以下问题:Golang CloudFormer类的具体用法?Golang CloudFormer怎么用?Golang CloudFormer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: buildInternetGateways

func (builder *Builder) buildInternetGateways(former cloudformer.CloudFormer) error {
	for _, x := range builder.spec.InternetGateways {
		builder.gateways[x.Name] = former.InternetGateway(x.Name)
	}

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:7,代码来源:builder.go


示例2: buildBuckets

func (builder *Builder) buildBuckets(former cloudformer.CloudFormer) error {
	for _, x := range builder.spec.Buckets {
		former.Bucket(x.Name).Name(x.BucketName)
	}

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:7,代码来源:builder.go


示例3: buildElasticIPs

func (builder *Builder) buildElasticIPs(former cloudformer.CloudFormer) error {
	for _, x := range builder.spec.ElasticIPs {
		former.ElasticIP(x.Name).Domain("vpc")
	}

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:7,代码来源:builder.go


示例4: buildVPC

func (builder *Builder) buildVPC(former cloudformer.CloudFormer) error {
	vpc := former.VPC("")
	vpc.Network(cloudformer.CIDR(builder.spec.VPC.CIDR))

	vpc.AssociateDHCPOptions(cloudformer.DHCPOptions{
		DomainNameServers: builder.spec.DNS,
	})

	vpcGateway, found := builder.gateways[builder.spec.VPC.InternetGateway]
	if !found {
		return fmt.Errorf("unknown gateway for VPC: %s", builder.spec.VPC.InternetGateway)
	}

	vpc.AttachInternetGateway(vpcGateway)

	builder.vpc = vpc

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:19,代码来源:builder.go


示例5: buildLoadBalancers

func (builder *Builder) buildLoadBalancers(former cloudformer.CloudFormer) error {
	for _, x := range builder.spec.LoadBalancers {
		balancer := former.LoadBalancer(x.Name)

		for _, name := range x.Subnets {
			subnet, found := builder.subnets[name]
			if !found {
				return fmt.Errorf("unknown subnet: %s", name)
			}

			balancer.Subnet(subnet)
		}

		for _, listener := range x.Listeners {
			destinationPort := listener.Port
			if listener.DestinationPort != nil {
				destinationPort = *listener.DestinationPort
			}

			destinationProtocol := listener.Protocol
			if listener.DestinationProtocol != nil {
				destinationProtocol = *listener.DestinationProtocol
			}

			balancer.Listener(
				cloudformer.ProtocolType(listener.Protocol),
				listener.Port,
				cloudformer.ProtocolType(destinationProtocol),
				destinationPort,
				listener.SSLCertificateId,
			)
		}

		for _, name := range x.SecurityGroups {
			securityGroup, found := builder.securityGroups[name]
			if !found {
				return fmt.Errorf("unknown security group: %s", name)
			}

			balancer.SecurityGroup(securityGroup)
		}

		balancer.HealthCheck(cloudformer.HealthCheck{
			Protocol:           cloudformer.ProtocolType(x.HealthCheck.Target.Protocol),
			Port:               x.HealthCheck.Target.Port,
			Path:               x.HealthCheck.Target.Path,
			Interval:           time.Duration(x.HealthCheck.Interval) * time.Second,
			Timeout:            time.Duration(x.HealthCheck.Timeout) * time.Second,
			HealthyThreshold:   x.HealthCheck.HealthyThreshold,
			UnhealthyThreshold: x.HealthCheck.UnhealthyThreshold,
		})

		if x.DNSRecord != "" {
			balancer.RecordSet(x.DNSRecord, builder.spec.Domain)
		}

		if x.Scheme != "" {
			balancer.Scheme(x.Scheme)
		}

		balancer.CrossZone(x.CrossZone)
	}

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:65,代码来源:builder.go


示例6: buildSubnets

func (builder *Builder) buildSubnets(former cloudformer.CloudFormer) error {
	natAMI, found := NAT_AMIS[builder.region]
	if !found {
		return fmt.Errorf("unknown NAT image for region: %s", builder.region)
	}

	for _, x := range builder.spec.Subnets {
		if x.NAT == nil {
			continue
		}

		if x.RouteTable != nil && x.RouteTable.Instance != nil {
			continue
		}

		subnet := builder.vpc.Subnet(x.Name)
		subnet.Network(cloudformer.CIDR(x.CIDR))
		subnet.AvailabilityZone(x.AvailabilityZone)

		if x.RouteTable != nil {
			if x.RouteTable.InternetGateway != nil {
				gateway, found := builder.gateways[*x.RouteTable.InternetGateway]
				if !found {
					return fmt.Errorf("unknown gateway: %s", *x.RouteTable.InternetGateway)
				}

				subnet.RouteTable().InternetGateway(gateway)
			}
		}

		nat := subnet.Instance(x.NAT.Name)
		nat.Type(x.NAT.InstanceType)
		nat.PrivateIP(cloudformer.IP(x.NAT.IP))
		nat.KeyPair(x.NAT.KeyPairName)
		nat.Image(natAMI)
		nat.SourceDestCheck(false)

		securityGroup, found := builder.securityGroups[x.NAT.SecurityGroup]
		if !found {
			return fmt.Errorf("unknown security group: %s", x.NAT.SecurityGroup)
		}

		nat.SecurityGroup(securityGroup)

		ip := former.ElasticIP("NAT")
		ip.Domain("vpc")
		ip.AttachTo(nat)

		builder.instances[x.NAT.Name] = nat
		builder.subnets[x.Name] = subnet
	}

	for _, x := range builder.spec.Subnets {
		if x.NAT != nil {
			continue
		}

		subnet := builder.vpc.Subnet(x.Name)
		subnet.Network(cloudformer.CIDR(x.CIDR))
		subnet.AvailabilityZone(x.AvailabilityZone)

		if x.RouteTable != nil {
			if x.RouteTable.Instance != nil {
				instance, found := builder.instances[*x.RouteTable.Instance]
				if !found {
					return fmt.Errorf("unknown instance: %s", *x.RouteTable.Instance)
				}

				subnet.RouteTable().Instance(instance)
			}

			if x.RouteTable.InternetGateway != nil {
				gateway, found := builder.gateways[*x.RouteTable.InternetGateway]
				if !found {
					return fmt.Errorf("unknown gateway: %s", *x.RouteTable.InternetGateway)
				}

				subnet.RouteTable().InternetGateway(gateway)
			}
		}

		builder.subnets[x.Name] = subnet
	}

	return nil
}
开发者ID:mmb,项目名称:boosh,代码行数:86,代码来源:builder.go


示例7: Form

func Form(f cloudformer.CloudFormer) {
	zone1 := "us-east-1a"

	vpc := f.VPC("Drone")
	vpc.Network(cloudformer.CIDR("10.10.0.0/16"))

	vpcGateway := f.InternetGateway("Drone")

	vpc.AttachInternetGateway(vpcGateway)

	openSecurityGroup := vpc.SecurityGroup("Open")
	boshSecurityGroup := vpc.SecurityGroup("BOSH")
	internalSecurityGroup := vpc.SecurityGroup("Internal")
	webSecurityGroup := vpc.SecurityGroup("Web")

	for _, group := range []cloudformer.SecurityGroup{
		openSecurityGroup,
		boshSecurityGroup,
		internalSecurityGroup,
	} {
		group.Ingress(cloudformer.TCP, cloudformer.CIDR("0.0.0.0/0"), 0, 65535)
		group.Ingress(cloudformer.UDP, cloudformer.CIDR("0.0.0.0/0"), 0, 65535)
	}

	webSecurityGroup.Ingress(cloudformer.TCP, cloudformer.CIDR("0.0.0.0/0"), 80, 80)
	webSecurityGroup.Ingress(cloudformer.TCP, cloudformer.CIDR("0.0.0.0/0"), 8080, 8080)

	boshSubnet := vpc.Subnet("BOSH")
	boshSubnet.Network(cloudformer.CIDR("10.10.0.0/24"))
	boshSubnet.AvailabilityZone(zone1)
	boshSubnet.RouteTable().InternetGateway(vpcGateway)

	droneELBSubnet := vpc.Subnet("DroneELB")
	droneELBSubnet.Network(cloudformer.CIDR("10.10.2.0/24"))
	droneELBSubnet.AvailabilityZone(zone1)
	droneELBSubnet.RouteTable().InternetGateway(vpcGateway)

	droneSubnet := vpc.Subnet("Drone")
	droneSubnet.Network(cloudformer.CIDR("10.10.16.0/20"))
	droneSubnet.AvailabilityZone(zone1)

	boshNAT := boshSubnet.Instance("NAT")
	boshNAT.Type("m1.small")
	boshNAT.Image("ami-something")
	boshNAT.PrivateIP(cloudformer.IP("10.10.0.10"))
	boshNAT.KeyPair("bosh")
	boshNAT.SecurityGroup(openSecurityGroup)

	droneSubnet.RouteTable().Instance(boshNAT)

	balancer := f.LoadBalancer("Drone")
	balancer.Listener(cloudformer.TCP, 80, cloudformer.TCP, 80, "")
	balancer.Listener(cloudformer.TCP, 8080, cloudformer.TCP, 8080, "")
	balancer.HealthCheck(cloudformer.HealthCheck{
		Protocol:           cloudformer.TCP,
		Port:               80,
		Timeout:            5 * time.Second,
		Interval:           30 * time.Second,
		HealthyThreshold:   10,
		UnhealthyThreshold: 2,
	})
	balancer.Subnet(droneELBSubnet)
	balancer.SecurityGroup(webSecurityGroup)
}
开发者ID:mmb,项目名称:cloudformer,代码行数:64,代码来源:drone.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sse.Event类代码示例发布时间:2022-05-28
下一篇:
Golang command.Command类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap