Exemplo n.º 1
0
	"strings"
)

type runMachineActionsArgs struct {
	box           *provision.Box
	writer        io.Writer
	machineStatus utils.Status
	provisioner   *chefsoloProvisioner
}

var updateStatusInRiak = action.Action{
	Name: "update-status-riak",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		args := ctx.Params[0].(runMachineActionsArgs)
		fmt.Fprintf(args.writer, "  update status for machine (%s, %s)", args.box.GetFullName(), args.machineStatus.String())
		var mach machine.Machine
		if ctx.Previous != nil && strings.Compare(reflect.TypeOf(ctx.Previous).Name(), "Machine") == 0 {
			mach = ctx.Previous.(machine.Machine)
		} else {
			mach = machine.Machine{
				Id:       args.box.Id,
				CartonId: args.box.CartonId,
				Level:    args.box.Level,
				Name:     args.box.GetFullName(),
				SSH:      args.box.SSH,
				Status:   args.machineStatus,
			}
		}
		if err := mach.SetStatus(mach.Status); err != nil {
			fmt.Fprintf(args.writer, "  update status for machine failed.\n")
			return err, nil
Exemplo n.º 2
0
type runMachineActionsArgs struct {
	box           *provision.Box
	writer        io.Writer
	machineStatus utils.Status
	machineState  utils.State
	provisioner   *chefsoloProvisioner
	state         string
}

var updateStatusInScylla = action.Action{
	Name: "update-status-scylla",
	Forward: func(ctx action.FWContext) (action.Result, error) {
		args := ctx.Params[0].(runMachineActionsArgs)
		fmt.Fprintf(args.writer, lb.W(args.machineStatus.String(), lb.INFO, fmt.Sprintf("  update status for machine (%s, %s)", args.box.GetFullName(), args.machineStatus.String())))
		var mach machine.Machine
		if ctx.Previous != nil && strings.Compare(reflect.TypeOf(ctx.Previous).Name(), "Machine") == 0 {
			mach = ctx.Previous.(machine.Machine)
		} else {
			mach = machine.Machine{
				Id:        args.box.Id,
				CartonId:  args.box.CartonId,
				CartonsId: args.box.CartonsId,
				Level:     args.box.Level,
				Name:      args.box.GetFullName(),
				SSH:       args.box.SSH,
				Status:    args.machineStatus,
				State:     args.machineState,
			}
		}
		if err := mach.SetStatus(mach.Status); err != nil {