// MachinesWithTransientErrors returns status data for machines with provisioning // errors which are transient. func (p *ProvisionerAPI) MachinesWithTransientErrors() (params.StatusResults, error) { results := params.StatusResults{} canAccessFunc, err := p.getAuthFunc() if err != nil { return results, err } // TODO (wallyworld) - add state.State API for more efficient machines query machines, err := p.st.AllMachines() if err != nil { return results, err } for _, machine := range machines { if !canAccessFunc(machine.Tag()) { continue } if _, provisionedErr := machine.InstanceId(); provisionedErr == nil { // Machine may have been provisioned but machiner hasn't set the // status to Started yet. continue } result := params.StatusResult{} if result.Status, result.Info, result.Data, err = machine.Status(); err != nil { continue } if result.Status != params.StatusError { continue } // Transient errors are marked as such in the status data. if transient, ok := result.Data["transient"].(bool); !ok || !transient { continue } result.Id = machine.Id() result.Life = params.Life(machine.Life().String()) results.Results = append(results.Results, result) } return results, nil }
func (s *StatusGetter) getEntityStatus(tag names.Tag) params.StatusResult { var result params.StatusResult entity, err := s.st.FindEntity(tag) if err != nil { result.Error = ServerError(err) return result } switch getter := entity.(type) { case status.StatusGetter: statusInfo, err := getter.Status() result.Status = statusInfo.Status result.Info = statusInfo.Message result.Data = statusInfo.Data result.Since = statusInfo.Since result.Error = ServerError(err) default: result.Error = ServerError(NotSupportedError(tag, fmt.Sprintf("getting status, %T", getter))) } return result }