當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CloudFormer.ElasticIP方法代碼示例

本文整理匯總了Golang中github.com/vito/cloudformer.CloudFormer.ElasticIP方法的典型用法代碼示例。如果您正苦於以下問題:Golang CloudFormer.ElasticIP方法的具體用法?Golang CloudFormer.ElasticIP怎麽用?Golang CloudFormer.ElasticIP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/vito/cloudformer.CloudFormer的用法示例。


在下文中一共展示了CloudFormer.ElasticIP方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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


注:本文中的github.com/vito/cloudformer.CloudFormer.ElasticIP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。