コード例 #1
0
ファイル: provisioner.go プロジェクト: rajthilakmca/gulp
//initialize the provisioner and setup the requirements for provisioner
func (p *chefsoloProvisioner) Initialize(m map[string]string) error {
	var outBuffer bytes.Buffer
	start := time.Now()

	p.Cookbook = m[CHEFREPO_COOKBOOK]
	logWriter := carton.NewLogWriter(&provision.Box{CartonName: m[NAME]})
	writer := io.MultiWriter(&outBuffer, &logWriter)
	defer logWriter.Close()

	cr := NewChefRepo(m, writer)
	if err := cr.Download(true); err != nil {
		err = provision.EventNotify(constants.StatusCookbookFailure)
		return err
	}
	if err := cr.Torr(); err != nil {
		err = provision.EventNotify(constants.StatusCookbookFailure)
		return err
	}
	elapsed := time.Since(start)

	log.Debugf("%s in (%s)\n%s",
		cmd.Colorfy(m[NAME], "cyan", "", "bold"),
		cmd.Colorfy(elapsed.String(), "green", "", "bold"),
		cmd.Colorfy(outBuffer.String(), "yellow", "", ""))
	_ = provision.EventNotify(constants.StatusCookbookSuccess)
	return nil
}
コード例 #2
0
ファイル: actions.go プロジェクト: rajthilakmca/gulp
func networkExecutor(networks *runNetworkActionsArgs) (action.Result, error) {
	var e exec.OsExecutor
	var commandWords []string
	commandWords = strings.Fields(networks.Command)
	if len(commandWords) > 0 {
		if err := e.Execute(commandWords[0], commandWords[1:], nil, nil, nil); err != nil {
			_ = provision.EventNotify(constants.StatusContainerNetworkFailure)
			return nil, err
		}
	}
	_ = provision.EventNotify(constants.StatusContainerNetworkSuccess)
	return &networks, nil
}
コード例 #3
0
ファイル: chefrepo.go プロジェクト: vijaykanthm28/gulp
//try downloading tar first, if not, do a clone of the chef-repo
func (ch *ChefRepo) Download(force bool) error {
	_ = provision.EventNotify(constants.StatusCookbookDownloading)
	fmt.Fprintf(ch.writer, lb.W(lb.VM_DEPLOY, lb.INFO, fmt.Sprintf("--- download (%s)\n", ch.repodir())))
	if !ch.exists() || !ch.isUptodate() {
		if err := ch.download(force); err != nil {
			return scm().Clone(repository.Repo{URL: ch.git})
		}
	}
	fmt.Fprintf(ch.writer, lb.W(lb.VM_DEPLOY, lb.INFO, fmt.Sprintf("--- download (%s)OK\n", ch.repodir())))
	return nil
}
コード例 #4
0
ファイル: actions.go プロジェクト: rajthilakmca/gulp
}

var updateIpsInRiak = action.Action{
	Name: "update-ips-riak",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		mach := ctx.Previous.(machine.Machine)
		args := ctx.Params[0].(runMachineActionsArgs)
		fmt.Fprintf(args.writer, "  update ips for box (%s)\n", args.box.GetFullName())

		err := mach.FindAndSetIps()
		if err != nil {
			fmt.Fprintf(args.writer, "  update ips for box failed\n%s\n", err.Error())
			return nil, err
		}
		fmt.Fprintf(args.writer, "  update ips for box (%s) OK\n", args.box.GetFullName())
		err = provision.EventNotify(constants.StatusIpsSuccess)
		return mach, nil
	},
	Backward: func(ctx action.BWContext) {
		c := ctx.FWResult.(machine.Machine)
		c.Status = constants.StatusError
		_ = provision.EventNotify(constants.StatusIpsFailure)
	},
}

var appendAuthKeys = action.Action{
	Name: "append-auth-keys",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		mach := ctx.Previous.(machine.Machine)
		args := ctx.Params[0].(runMachineActionsArgs)
		fmt.Fprintf(args.writer, "  append authorized keys for box (%s)\n", args.box.GetFullName())
コード例 #5
0
ファイル: actions.go プロジェクト: rajthilakmca/gulp
	Command   string
	HomeDir   string
	Writer    io.Writer
	CloseChan chan bool
}

var setNetwork = action.Action{
	Name: "attach-network-docker",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		args := ctx.Params[0].(runNetworkActionsArgs)
		network_command := args.HomeDir + "/" + PIPEWORK + " " + args.Bridge + " " + parseID(args.Id) + " " + args.IpAddr + "/24@" + args.Gateway
		args.Command = network_command
		return networkExecutor(&args)
	},
	Backward: func(ctx action.BWContext) {
		_ = provision.EventNotify(constants.StatusContainerNetworkFailure)
	},
}

var setLogs = action.Action{
	Name: "attachlogs-docker",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		args := ctx.Params[0].(runLogsActionsArgs)
		return logExecutor(&args)
	},
	Backward: func(ctx action.BWContext) {

	},
}

func networkExecutor(networks *runNetworkActionsArgs) (action.Result, error) {
コード例 #6
0
ファイル: actions.go プロジェクト: vijaykanthm28/gulp
	Backward: func(ctx action.BWContext) {},
}

var updateIpsInSyclla = action.Action{
	Name: "update-ips-scylla",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		mach := ctx.Previous.(machine.Machine)
		args := ctx.Params[0].(runMachineActionsArgs)
		fmt.Fprintf(args.writer, lb.W(lb.VM_DEPLOY, lb.INFO, fmt.Sprintf("  update ips for box (%s)\n", args.box.GetFullName())))
		err := mach.FindAndSetIps()
		if err != nil {
			fmt.Fprintf(args.writer, lb.W(lb.VM_DEPLOY, lb.ERROR, fmt.Sprintf("  update ips for box failed\n%s\n", err.Error())))
			return nil, err
		}
		fmt.Fprintf(args.writer, lb.W(lb.VM_DEPLOY, lb.INFO, fmt.Sprintf("  update ips for box (%s) OK\n", args.box.GetFullName())))
		err = provision.EventNotify(constants.StatusIpsUpdated)
		mach.Status = constants.StatusAuthkeysUpdating
		return mach, nil
	},
	Backward: func(ctx action.BWContext) {
		c := ctx.FWResult.(machine.Machine)
		c.Status = constants.StatusError
		c.State = constants.StatePreError
		_ = provision.EventNotify(constants.StatusIpsFailure)
	},
}

var appendAuthKeys = action.Action{
	Name: "append-auth-keys",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		mach := ctx.Previous.(machine.Machine)