コード例 #1
0
ファイル: provisioner.go プロジェクト: rajthilakmca/gulp
func (p *chefsoloProvisioner) Bootstrap(box *provision.Box, w io.Writer) error {
	fmt.Fprintf(w, "--- bootstrap box (%s)\n", box.GetFullName())
	actions := []*action.Action{
		&createMachine,
		&updateStatusInRiak,
		&updateIpsInRiak,
		&appendAuthKeys,
		&updateStatusInRiak,
		&changeStateofMachine,
	}

	pipeline := action.NewPipeline(actions...)

	args := runMachineActionsArgs{
		box:           box,
		writer:        w,
		machineStatus: constants.StatusBootstrapping,
		provisioner:   p,
	}

	if err := pipeline.Execute(args); err != nil {
		return err
	}
	fmt.Fprintf(w, "--- bootstrap box (%s) OK\n", box.GetFullName())
	return nil
}
コード例 #2
0
ファイル: provisioner.go プロジェクト: rajthilakmca/gulp
func (p *chefsoloProvisioner) Stateup(b *provision.Box, w io.Writer) error {
	fmt.Fprintf(w, "--- stateup box (%s)\n", b.GetFullName())
	var repo string
	if b.Repo != nil {
		repo = b.Repo.Gitr()
	}

	DefaultAttributes, _ := json.Marshal(&Attributes{
		RunList:   []string{"recipe[" + p.Cookbook + "]"},
		ToscaType: b.GetShortTosca(),
		Scm:       repo,
	})

	p.Attributes = string(DefaultAttributes)
	p.Format = DefaultFormat
	p.LogLevel = DefaultLogLevel
	p.RootPath = meta.MC.Dir
	p.Sudo = DefaultSudo
	return p.kickOffSolo(b, w)
}
コード例 #3
0
ファイル: provisioner.go プロジェクト: rajthilakmca/gulp
func (p *chefsoloProvisioner) Stop(b *provision.Box, w io.Writer) error {
	fmt.Fprintf(w, "--- stop box (%s)\n", b.GetFullName())
	actions := []*action.Action{
		&updateStatusInRiak,
		&stopBox,
		&updateStatusInRiak,
	}
	pipeline := action.NewPipeline(actions...)
	args := runMachineActionsArgs{
		box:           b,
		writer:        w,
		machineStatus: constants.StatusStopping,
		provisioner:   p,
	}

	if err := pipeline.Execute(args); err != nil {
		log.Errorf("error on execute stop pipeline for box %s - %s", b.GetFullName(), err)
		return err
	}
	fmt.Fprintf(w, "--- stop box (%s) OK\n", b.GetFullName())
	return nil
}
コード例 #4
0
ファイル: provisioner.go プロジェクト: rajthilakmca/gulp
//1. &prepareJSON in generate the json file for chefsolo
//2. &prepareConfig in generate the config file for chefsolo.
//3. &updateStatus in Riak - Creating..
func (p *chefsoloProvisioner) kickOffSolo(b *provision.Box, w io.Writer) error {
	fmt.Fprintf(w, "--- kickofff chefsolo box (%s)\n", b.GetFullName())
	soloAction := make([]*action.Action, 0, 4)
	soloAction = append(soloAction, &generateSoloJson, &generateSoloConfig, &cloneBox)
	if b.Level != provision.BoxNone {
		soloAction = append(soloAction, &chefSoloRun)
	}
	soloAction = append(soloAction, &updateStatusInRiak)
	actions := soloAction
	pipeline := action.NewPipeline(actions...)
	args := runMachineActionsArgs{
		box:           b,
		writer:        w,
		machineStatus: constants.StatusRunning,
		provisioner:   p,
	}

	if err := pipeline.Execute(args); err != nil {
		log.Errorf("error on execute chefsolo pipeline for box %s - %s", b.GetFullName(), err)
		return err
	}
	fmt.Fprintf(w, "--- kickofff chefsolo box (%s) OK\n", b.GetFullName())
	return nil
}