// Status returns the status of the unit agent.
543932
func (u *UnitAgent) Status() (status.StatusInfo, error) {
	info, err := getStatus(u.st.db(), u.globalKey(), "agent")
	if err != nil {
		return status.StatusInfo{}, errors.Trace(err)
	}
	// The current health spec says when a hook error occurs, the workload should
	// be in error state, but the state model more correctly records the agent
	// itself as being in error. So we'll do that model translation here.
	// TODO(fwereade): this should absolutely not be happpening in the model.
	// TODO: when fixed, also fix code in status.go for UnitAgent.
	if info.Status == status.Error {
		return status.StatusInfo{
			Status:  status.Idle,
			Message: "",
			Data:    map[string]interface{}{},
			Since:   info.Since,
		}, nil
	}
	return info, nil
}
1176559
func (c *criOClient) Status() *models.Status {
	if c == nil {
		return &models.Status{State: models.StatusStateDisabled}
	}

	criStatus := c.cri.Status()
	criStatusMsg := fmt.Sprintf("cri-o client: %s - %s", criStatus.State, criStatus.Msg)

	return &models.Status{
		State: criStatus.State,
		Msg:   criStatusMsg,
	}
}
68353
func (s *ApplicationStatusGetter) Status(args params.Entities) (params.ApplicationStatusResults, error) {
	result := params.ApplicationStatusResults{
		Results: make([]params.ApplicationStatusResult, len(args.Entities)),
	}
	canAccess, err := s.getCanAccess()
	if err != nil {
		return params.ApplicationStatusResults{}, err
	}

	for i, arg := range args.Entities {
		// TODO(fwereade): the auth is basically nonsense, and basically only
		// works by coincidence (and is happening at the wrong layer anyway).
		// Read carefully.

		// We "know" that arg.Tag is either the calling unit or its application
		// (because getCanAccess is authUnitOrApplication, and we'll fail out if
		// it isn't); and, in practice, it's always going to be the calling
		// unit (because, /sigh, we don't actually use application tags to refer
		// to applications in this method).
		tag, err := names.ParseTag(arg.Tag)
		if err != nil {
			result.Results[i].Error = ServerError(err)
			continue
		}
		if !canAccess(tag) {
			result.Results[i].Error = ServerError(ErrPerm)
			continue
		}
		unitTag, ok := tag.(names.UnitTag)
		if !ok {
			// No matter what the canAccess says, if this entity is not
			// a unit, we say "NO".
			result.Results[i].Error = ServerError(ErrPerm)
			continue
		}
		unitId := unitTag.Id()

		// Now we have the unit, we can get the application that should have been
		// specified in the first place...
		applicationId, err := names.UnitApplication(unitId)
		if err != nil {
			result.Results[i].Error = ServerError(err)
			continue
		}
		application, err := s.st.Application(applicationId)
		if err != nil {
			result.Results[i].Error = ServerError(err)
			continue
		}

		// ...so we can check the unit's application leadership...
		token := s.leadershipChecker.LeadershipCheck(applicationId, unitId)
		if err := token.Check(0, nil); err != nil {
			// TODO(fwereade) this should probably be ErrPerm is certain cases,
			// but I don't think I implemented an exported ErrNotLeader. I
			// should have done, though.
			result.Results[i].Error = ServerError(err)
			continue
		}

		// ...and collect the results.
		applicationStatus, unitStatuses, err := application.ApplicationAndUnitsStatus()
		if err != nil {
			result.Results[i].Application.Error = ServerError(err)
			result.Results[i].Error = ServerError(err)
			continue
		}
		result.Results[i].Application.Status = applicationStatus.Status.String()
		result.Results[i].Application.Info = applicationStatus.Message
		result.Results[i].Application.Data = applicationStatus.Data
		result.Results[i].Application.Since = applicationStatus.Since

		result.Results[i].Units = make(map[string]params.StatusResult, len(unitStatuses))
		for uTag, r := range unitStatuses {
			ur := params.StatusResult{
				Status: r.Status.String(),
				Info:   r.Message,
				Data:   r.Data,
				Since:  r.Since,
			}
			result.Results[i].Units[uTag] = ur
		}
	}
	return result, nil
}
1308112
func (device *Device) status() error {
	ret := Status(C.cairo_device_status(device.Ptr)).toError()
	return ret
}
151966
func (i sigmaInstance) Status(ctx context.ProviderCallContext) instance.Status {
	entityStatus := i.server.Status()
	logger.Tracef("sigmaInstance.Status: %s", entityStatus)
	jujuStatus := status.Pending
	switch entityStatus {
	case gosigma.ServerStarting:
		jujuStatus = status.Allocating
	case gosigma.ServerRunning:
		jujuStatus = status.Running
	case gosigma.ServerStopping, gosigma.ServerStopped:
		jujuStatus = status.Empty
	case gosigma.ServerUnavailable:
		// I am not sure about this one.
		jujuStatus = status.Pending
	default:
		jujuStatus = status.Pending
	}

	return instance.Status{
		Status:  jujuStatus,
		Message: entityStatus,
	}

}
191570
func (f Future) Status() string {
	if f.pt == nil {
		return ""
	}
	return f.pt.pollingStatus()
}
96267
func (nc *Conn) Status() Status {
	nc.mu.RLock()
	defer nc.mu.RUnlock()
	return nc.status
}
1270554
func (kvm *kvmInstance) Status(ctx context.ProviderCallContext) instance.Status {
	if kvm.container.IsRunning() {
		return instance.Status{
			Status:  status.Running,
			Message: "running",
		}
	}
	return instance.Status{
		Status:  status.Stopped,
		Message: "stopped",
	}
}
356870
func (r *Response) Status(status int) *Response {
	if r.chain.failed() {
		return r
	}
	r.checkEqual("status", statusCodeText(status), statusCodeText(r.resp.StatusCode))
	return r
}
336759
func (p *Package) Status() JobStatus {
	p.statusLock.RLock()
	defer p.statusLock.RUnlock()

	return p.status
}
750690
func (d *dockerClient) Status() *models.Status {
	if d == nil {
		return &models.Status{State: models.StatusStateDisabled}
	}

	if _, err := d.Info(ctx.Background()); err != nil {
		return &models.Status{State: models.StatusStateFailure, Msg: "docker daemon: " + err.Error()}
	}

	return &models.Status{State: models.StatusStateOk, Msg: "docker daemon: OK"}
}
90509
func (r *Relation) Status() (status.StatusInfo, error) {
	rStatus, err := getStatus(r.st.db(), r.globalScope(), "relation")
	if err != nil {
		return rStatus, err
	}
	return rStatus, nil
}
1194643
func (u *UnitAgent) SetStatus(unitAgentStatus status.StatusInfo) (err error) {
	unit, err := u.st.Unit(u.name)
	if errors.IsNotFound(err) {
		return errors.Annotate(errors.NotFoundf("agent"), "cannot set status")
	}
	if err != nil {
		return errors.Trace(err)
	}
	isAssigned := unit.doc.MachineId != ""
	shouldBeAssigned := unit.ShouldBeAssigned()
	isPrincipal := unit.doc.Principal == ""

	switch unitAgentStatus.Status {
	case status.Idle, status.Executing, status.Rebooting, status.Failed:
		if !isAssigned && isPrincipal && shouldBeAssigned {
			return errors.Errorf("cannot set status %q until unit is assigned", unitAgentStatus.Status)
		}
	case status.Error:
		if unitAgentStatus.Message == "" {
			return errors.Errorf("cannot set status %q without info", unitAgentStatus.Status)
		}
	case status.Allocating:
		if isAssigned {
			return errors.Errorf("cannot set status %q as unit is already assigned", unitAgentStatus.Status)
		}
	case status.Running:
		// Only CAAS units (those that require assignment) can have a status of running.
		if shouldBeAssigned {
			return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status)
		}
	case status.Lost:
		return errors.Errorf("cannot set status %q", unitAgentStatus.Status)
	default:
		return errors.Errorf("cannot set invalid status %q", unitAgentStatus.Status)
	}
	return setStatus(u.st.db(), setStatusParams{
		badge:     "agent",
		globalKey: u.globalKey(),
		status:    unitAgentStatus.Status,
		message:   unitAgentStatus.Message,
		rawData:   unitAgentStatus.Data,
		updated:   timeOrNow(unitAgentStatus.Since, u.st.clock()),
	})
}
573979
func (b *SinkHandler) Status() (int, int) {
	return b.bufSize, len(b.sinkCh)
}
1263934
func (m *kubeGenericRuntimeManager) Status() (*kubecontainer.RuntimeStatus, error) {
	status, err := m.runtimeService.Status()
	if err != nil {
		return nil, err
	}
	return toKubeRuntimeStatus(status), nil
}
886708
func (c *SearchCall) Status(status string) *SearchCall {
	c.urlParams_.Set("status", status)
	return c
}
1081234
func (s *StatusAPI) UnitStatus(args params.Entities) (params.StatusResults, error) {
	return s.unitGetter.Status(args)
}