本文整理汇总了Golang中github.com/globocom/tsuru/provision.Named.GetName方法的典型用法代码示例。如果您正苦于以下问题:Golang Named.GetName方法的具体用法?Golang Named.GetName怎么用?Golang Named.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/globocom/tsuru/provision.Named
的用法示例。
在下文中一共展示了Named.GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Destroy
// Destroy destroys an Elastic Load Balancing instance from AWS. It matches the
// name of the given app.
func (m *ELBManager) Destroy(app provision.Named) error {
_, err := m.elb().DeleteLoadBalancer(app.GetName())
if err != nil {
return err
}
return m.collection().Remove(bson.M{"name": app.GetName()})
}
示例2: Addr
// Addr returns the dns-name of a load balancer, which is also the DNS name of
// the app.
func (m *ELBManager) Addr(app provision.Named) (string, error) {
var lb loadBalancer
conn, collection := m.collection()
defer conn.Close()
err := collection.Find(bson.M{"name": app.GetName()}).One(&lb)
return lb.DNSName, err
}
示例3: Deregister
// Deregister removes EC2 instances (represented as units) from a load
// balancer.
func (m *ELBManager) Deregister(app provision.Named, units ...provision.Unit) error {
ids := make([]string, len(units))
for i, u := range units {
ids[i] = u.InstanceId
}
_, err := m.elb().DeregisterInstancesFromLoadBalancer(ids, app.GetName())
return err
}
示例4: Create
// Create creates a new Elastic Load Balancing instance for the given app. The
// name of the instance will be the same as the name of the app.
func (m *ELBManager) Create(app provision.Named) error {
options := elb.CreateLoadBalancer{
Name: app.GetName(),
Listeners: []elb.Listener{
{
InstancePort: 80,
InstanceProtocol: "HTTP",
LoadBalancerPort: 80,
Protocol: "HTTP",
},
},
}
var err error
if m.vpc() {
options.Subnets, err = config.GetList("juju:elb-vpc-subnets")
if err != nil {
log.Fatal(err)
}
options.SecurityGroups, err = config.GetList("juju:elb-vpc-secgroups")
if err != nil {
log.Fatal(err)
}
options.Scheme = "internal"
} else {
options.AvailZones, err = config.GetList("juju:elb-avail-zones")
if err != nil {
log.Fatal(err)
}
}
resp, err := m.elb().CreateLoadBalancer(&options)
if err != nil {
return err
}
lb := loadBalancer{Name: app.GetName(), DNSName: resp.DNSName}
conn, collection := m.collection()
defer conn.Close()
return collection.Insert(lb)
}