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


Golang App.ProvisionedUnits方法代码示例

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


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

示例1: startedUnits

func (*JujuProvisioner) startedUnits(app provision.App) []provision.AppUnit {
	units := []provision.AppUnit{}
	allUnits := app.ProvisionedUnits()
	for _, unit := range allUnits {
		if unit.Available() {
			units = append(units, unit)
		}
	}
	return units
}
开发者ID:rochacon,项目名称:tsuru,代码行数:10,代码来源:provisioner.go

示例2: deleteUnits

func (p *JujuProvisioner) deleteUnits(app provision.App) {
	units := app.ProvisionedUnits()
	names := make([]string, len(units))
	for i, u := range units {
		names[i] = u.GetName()
	}
	collection := p.unitsCollection()
	defer collection.Close()
	collection.RemoveAll(bson.M{"_id": bson.M{"$in": names}})
}
开发者ID:rochacon,项目名称:tsuru,代码行数:10,代码来源:provisioner.go

示例3: ExecuteCommand

// ExecuteCommand will pretend to execute the given command, recording data
// about it.
//
// The output of the command must be prepared with PrepareOutput, and failures
// must be prepared with PrepareFailure. In case of failure, the prepared
// output will be sent to the standard error stream, otherwise, it will be sent
// to the standard error stream.
//
// When there is no output nor failure prepared, ExecuteCommand will return a
// timeout error.
func (p *FakeProvisioner) ExecuteCommand(stdout, stderr io.Writer, app provision.App, cmd string, args ...string) error {
	var (
		output []byte
		err    error
	)
	command := Cmd{
		Cmd:  cmd,
		Args: args,
		App:  app,
	}
	p.cmdMut.Lock()
	p.cmds = append(p.cmds, command)
	p.cmdMut.Unlock()
	for _ = range app.ProvisionedUnits() {
		select {
		case output = <-p.outputs:
			select {
			case fail := <-p.failures:
				if fail.method == "ExecuteCommand" {
					stderr.Write(output)
					return fail.err
				}
				p.failures <- fail
			default:
				stdout.Write(output)
			}
		case fail := <-p.failures:
			if fail.method == "ExecuteCommand" {
				err = fail.err
				select {
				case output = <-p.outputs:
					stderr.Write(output)
				default:
				}
			} else {
				p.failures <- fail
			}
		case <-time.After(2e9):
			return errors.New("FakeProvisioner timed out waiting for output.")
		}
	}
	return err
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:53,代码来源:provisioner.go

示例4: RemoveUnit

func (p *JujuProvisioner) RemoveUnit(app provision.App, name string) error {
	var unit provision.AppUnit
	for _, unit = range app.ProvisionedUnits() {
		if unit.GetName() == name {
			break
		}
	}
	if unit.GetName() != name {
		return fmt.Errorf("App %q does not have a unit named %q.", app.GetName(), name)
	}
	return p.removeUnit(app, unit)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:12,代码来源:provisioner.go

示例5: Addr

func (p *JujuProvisioner) Addr(app provision.App) (string, error) {
	if p.elbSupport() {
		router, err := Router()
		if err != nil {
			return "", err
		}
		addr, err := router.Addr(app.GetName())
		if err != nil {
			return "", fmt.Errorf("There is no ACTIVE Load Balancer named %s", app.GetName())
		}
		return addr, nil
	}
	units := app.ProvisionedUnits()
	if len(units) < 1 {
		return "", fmt.Errorf("App %q has no units.", app.GetName())
	}
	return units[0].GetIp(), nil
}
开发者ID:rochacon,项目名称:tsuru,代码行数:18,代码来源:provisioner.go

示例6: terminateMachines

func (p *JujuProvisioner) terminateMachines(app provision.App, units ...provision.AppUnit) error {
	var buf bytes.Buffer
	if len(units) < 1 {
		units = app.ProvisionedUnits()
	}
	for _, u := range units {
		buf.Reset()
		err := runCmd(false, &buf, &buf, "terminate-machine", strconv.Itoa(u.GetMachine()))
		out := buf.String()
		if err != nil {
			msg := fmt.Sprintf("Failed to destroy unit %s: %s", u.GetName(), out)
			app.Log(msg, "tsuru")
			log.Errorf("Failed to destroy unit %q from the app %q: %s", u.GetName(), app.GetName(), out)
			return cmdError(out, err, []string{"terminate-machine", strconv.Itoa(u.GetMachine())})
		}
	}
	return nil
}
开发者ID:rochacon,项目名称:tsuru,代码行数:18,代码来源:provisioner.go


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