コード例 #1
0
ファイル: deploy.go プロジェクト: adevendra/atlantis-manager
func (e *DeployContainerExecutor) Execute(t *Task) error {
	if e.arg.ContainerID == "" {
		return errors.New("Container ID is empty")
	}
	if e.arg.Instances <= 0 {
		return errors.New("Instances should be > 0")
	}
	instance, err := datamodel.GetInstance(e.arg.ContainerID)
	if err != nil {
		return err
	}
	ihReply, err := supervisor.Get(instance.Host, instance.ID)
	if err != nil {
		return err
	}
	e.reply.Containers, err = deployContainer(&e.arg.ManagerAuthArg, ihReply.Container, e.arg.Instances, t)
	return err
}
コード例 #2
0
func copyContainer(auth *ManagerAuthArg, cid, toHost string, t *Task) (*Container, error) {
	// get old instance
	inst, err := datamodel.GetInstance(cid)
	if err != nil {
		return nil, err
	}

	// get manifest
	manifest := inst.Manifest
	if manifest == nil {
		// if we don't have the manifest in zk, try to get it from the supervisor
		ihReply, err := supervisor.Get(inst.Host, inst.ID)
		if err != nil {
			return nil, err
		}
		manifest = ihReply.Container.Manifest
	}
	manifest.Instances = 1

	// validate and get deps
	deps, err := validateDeploy(auth, manifest, inst.Sha, inst.Env, t)
	if err != nil {
		return nil, err
	}

	// get zone of toHost
	zone, err := supervisor.GetZone(toHost)
	if err != nil {
		return nil, err
	}

	deployed, err := deployToHostsInZones(deps, manifest, inst.Sha, inst.Env,
		map[string][]string{zone: []string{toHost}}, []string{zone}, t)
	if err != nil {
		return nil, err
	}
	// should only deploy 1 since we're only moving 1
	if len(deployed) != 1 {
		cleanup(true, deployed, t)
		return nil, errors.New(fmt.Sprintf("Didn't deploy 1 container. Deployed %d", len(deployed)))
	}
	return deployed[0], nil
}
コード例 #3
0
func (e *GetContainerExecutor) Execute(t *Task) (err error) {
	if e.arg.ContainerID == "" {
		return errors.New("Container ID is empty")
	}
	instance, err := datamodel.GetInstance(e.arg.ContainerID)
	if err != nil {
		e.reply.Status = StatusError
		return err
	}
	var ihReply *SupervisorGetReply
	ihReply, err = supervisor.Get(instance.Host, e.arg.ContainerID)
	if err != nil {
		e.reply.Status = StatusError
		return err
	}
	e.reply.Status = ihReply.Status
	ihReply.Container.Host = instance.Host
	e.reply.Container = ihReply.Container
	e.reply.Status = StatusOk
	return err
}