// SetStatus sets the status of the unit. func (u *Unit) SetStatus(unitStatus status.Status, info string, data map[string]interface{}) error { var result params.ErrorResults args := params.SetStatus{ Entities: []params.EntityStatusArgs{ {Tag: u.tag.String(), Status: unitStatus.String(), Info: info, Data: data}, }, } err := u.st.facade.FacadeCall("SetStatus", args, &result) if err != nil { return err } return result.OneError() }
func matchAgentStatus(patterns []string, agentStatus status.Status) (bool, bool, error) { oneValidStatus := false for _, p := range patterns { // If the pattern isn't a known status, ignore it. ps := status.Status(p) if !ps.KnownAgentStatus() { continue } oneValidStatus = true if agentStatus.Matches(ps) { return true, true, nil } } return false, oneValidStatus, nil }
// SetUnitStatus sets the status of the unit. func (u *Unit) SetUnitStatus(unitStatus status.Status, info string, data map[string]interface{}) error { if u.st.facade.BestAPIVersion() < 2 { return errors.NotImplementedf("SetUnitStatus") } var result params.ErrorResults args := params.SetStatus{ Entities: []params.EntityStatusArgs{ {Tag: u.tag.String(), Status: unitStatus.String(), Info: info, Data: data}, }, } err := u.st.facade.FacadeCall("SetUnitStatus", args, &result) if err != nil { return errors.Trace(err) } return result.OneError() }
// SetAgentStatus sets the status of the unit agent. func (u *Unit) SetAgentStatus(agentStatus status.Status, info string, data map[string]interface{}) error { var result params.ErrorResults args := params.SetStatus{ Entities: []params.EntityStatusArgs{ {Tag: u.tag.String(), Status: agentStatus.String(), Info: info, Data: data}, }, } setStatusFacadeCall := "SetAgentStatus" if u.st.facade.BestAPIVersion() < 2 { setStatusFacadeCall = "SetStatus" } err := u.st.facade.FacadeCall(setStatusFacadeCall, args, &result) if err != nil { return err } return result.OneError() }
func matchWorkloadStatus(patterns []string, workloadStatus status.Status, agentStatus status.Status) (bool, bool, error) { oneValidStatus := false for _, p := range patterns { // If the pattern isn't a known status, ignore it. ps := status.Status(p) if !ps.KnownWorkloadStatus() { continue } oneValidStatus = true // To preserve current expected behaviour, we only report on workload status // if the agent itself is not in error. if agentStatus != status.Error && workloadStatus.WorkloadMatches(ps) { return true, true, nil } } return false, oneValidStatus, nil }
// SetStatus sets the status of the service if the passed unitName, // corresponding to the calling unit, is of the leader. func (s *Application) SetStatus(unitName string, serviceStatus status.Status, info string, data map[string]interface{}) error { tag := names.NewUnitTag(unitName) var result params.ErrorResults args := params.SetStatus{ Entities: []params.EntityStatusArgs{ { Tag: tag.String(), Status: serviceStatus.String(), Info: info, Data: data, }, }, } err := s.st.facade.FacadeCall("SetApplicationStatus", args, &result) if err != nil { return errors.Trace(err) } return result.OneError() }
// SetInstanceStatus sets the status for the provider instance. func (m *Machine) SetInstanceStatus(status status.Status, message string, data map[string]interface{}) error { var result params.ErrorResults args := params.SetStatus{Entities: []params.EntityStatusArgs{ {Tag: m.tag.String(), Status: status.String(), Info: message, Data: data}, }} err := m.st.facade.FacadeCall("SetInstanceStatus", args, &result) if err != nil { return err } return result.OneError() }
// SetStatus sets the status of the model. func (c *Client) SetStatus(status status.Status, message string, data map[string]interface{}) error { args := params.SetStatus{ Entities: []params.EntityStatusArgs{ {c.modelTag.String(), status.String(), message, data}, }, } var results params.ErrorResults if err := c.caller.FacadeCall("SetStatus", args, &results); err != nil { return errors.Trace(err) } if len(results.Results) != 1 { return errors.Errorf("expected 1 result, got %d", len(results.Results)) } if results.Results[0].Error != nil { return errors.Trace(results.Results[0].Error) } return nil }