// SetInstanceStatus updates the instance status for each given // entity. Only machine tags are accepted. func (a *InstancePollerAPI) SetInstanceStatus(args params.SetStatus) (params.ErrorResults, error) { result := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } canAccess, err := a.accessMachine() if err != nil { return result, err } for i, arg := range args.Entities { machine, err := a.getOneMachine(arg.Tag, canAccess) if err == nil { now := a.clock.Now() s := status.StatusInfo{ Status: status.Status(arg.Status), Message: arg.Info, Data: arg.Data, Since: &now, } err = machine.SetInstanceStatus(s) if status.Status(arg.Status) == status.ProvisioningError { s.Status = status.Error if err == nil { err = machine.SetStatus(s) } } } result.Results[i].Error = common.ServerError(err) } return result, nil }
// SetInstanceStatus updates the instance status for each given // entity. Only machine tags are accepted. func (p *ProvisionerAPI) SetInstanceStatus(args params.SetStatus) (params.ErrorResults, error) { result := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } canAccess, err := p.getAuthFunc() if err != nil { logger.Errorf("failed to get an authorisation function: %v", err) return result, errors.Trace(err) } for i, arg := range args.Entities { mTag, err := names.ParseMachineTag(arg.Tag) if err != nil { result.Results[i].Error = common.ServerError(err) continue } machine, err := p.getMachine(canAccess, mTag) if err == nil { // TODO(perrito666) 2016-05-02 lp:1558657 now := time.Now() s := status.StatusInfo{ Status: status.Status(arg.Status), Message: arg.Info, Data: arg.Data, Since: &now, } err = machine.SetInstanceStatus(s) if status.Status(arg.Status) == status.ProvisioningError { s.Status = status.Error if err == nil { err = machine.SetStatus(s) } } } result.Results[i].Error = common.ServerError(err) } return result, nil }