// populateStatusFromStatusInfoAndErr creates AgentStatus from the typical output
// of a status getter.
// TODO: make this a function that just returns a type.
488868
func populateStatusFromStatusInfoAndErr(agent *params.DetailedStatus, statusInfo status.StatusInfo, err error) {
	agent.Err = common.ServerError(err)
	agent.Status = statusInfo.Status.String()
	agent.Info = statusInfo.Message
	agent.Data = filterStatusData(statusInfo.Data)
	agent.Since = statusInfo.Since
}
958458
func (u *upgrader) populateAgents() (err error) {
	var unknown []string
	u.machineAgent, u.unitAgents, unknown, err = u.manager.FindAgents(paths.NixDataDir)
	if err != nil {
		return errors.Trace(err)
	}
	if len(unknown) > 0 {
		u.logger.Warningf("skipping agents not of type machine or unit: %s", strings.Join(unknown, ", "))
	}
	return nil
}
622162
func (b *build) reportStatus(q *BuildQueue, success bool) {
	for _, notify := range b.notificationChannels {
		notify <- success
		close(notify)
	}
}
476418
func (c *ModelPresenceContext) MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error) {
	machineStatus, err := machine.Status()
	if err != nil {
		return status.StatusInfo{}, err
	}

	if !canMachineBeDown(machineStatus) {
		// The machine still being provisioned - there's no point in
		// enquiring about the agent liveness.
		return machineStatus, nil
	}

	agentAlive, err := c.machinePresence(machine)
	if err != nil {
		// We don't want any presence errors affecting status.
		logger.Debugf("error determining presence for machine %s: %v", machine.Id(), err)
		return machineStatus, nil
	}
	if machine.Life() != state.Dead && !agentAlive {
		machineStatus.Status = status.Down
		machineStatus.Message = "agent is not communicating with the server"
	}
	return machineStatus, nil
}
352753
func (c *ClusterManager) NodeStatus() (api.Status, error) {
	clusterNodeStatus := c.selfNode.Status

	if clusterNodeStatus != api.Status_STATUS_OK {
		// Status of this node as seen by Cluster Manager is not OK
		// This takes highest precedence over other listener statuses.
		// Returning our status
		return clusterNodeStatus, nil
	}

	for e := c.listeners.Front(); e != nil; e = e.Next() {
		listenerStatus := e.Value.(cluster.ClusterListener).ListenerStatus()
		if listenerStatus == api.Status_STATUS_NONE {
			continue
		}
		if int(listenerStatus.StatusKind()) >= int(clusterNodeStatus.StatusKind()) {
			clusterNodeStatus = listenerStatus
		}
	}

	return clusterNodeStatus, nil
}
513081
func NewStatusInfo(s status.StatusInfo, err error) StatusInfo {
	return StatusInfo{
		Err:     err,
		Current: s.Status,
		Message: s.Message,
		Since:   s.Since,
		Data:    s.Data,
	}
}
99398
func (env *maasEnviron) deploymentStatus(ctx context.ProviderCallContext, ids ...instance.Id) (map[string]string, error) {
	nodesAPI := env.getMAASClient().GetSubObject("nodes")
	result, err := DeploymentStatusCall(nodesAPI, ids...)
	if err != nil {
		if err, ok := errors.Cause(err).(gomaasapi.ServerError); ok && err.StatusCode == http.StatusBadRequest {
			return nil, errors.NewNotImplemented(err, "deployment status")
		}
		common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
		return nil, errors.Trace(err)
	}
	resultMap, err := result.GetMap()
	if err != nil {
		return nil, errors.Trace(err)
	}
	statusValues := make(map[string]string)
	for systemId, jsonValue := range resultMap {
		status, err := jsonValue.GetString()
		if err != nil {
			return nil, errors.Trace(err)
		}
		statusValues[systemId] = status
	}
	return statusValues, nil
}
1043902
func NewStatusStrategy(typer runtime.ObjectTyper) rest.RESTUpdateStrategy {
	return apiServerStatusStrategy{typer, names.SimpleNameGenerator}
}
408844
func isRetriableStatus(statusCode int) bool {
	switch statusCode {
	case http.StatusGatewayTimeout, http.StatusBadGateway, http.StatusServiceUnavailable:
		return true
	}
	return false
}
813821
func StatusInfoCtx(r *http.Request, source DataSource) context.Context {
	idx := int64(-1)
	h, err := source.GetHeight()
	if h >= 0 && err == nil {
		idx = h
	}
	ctx := context.WithValue(r.Context(), ctxBlockIndex, int(idx)) // Must be int!

	q := r.FormValue("q")
	return context.WithValue(ctx, ctxGetStatus, q)
}
563374
func StatusViewerFor(kind schema.GroupKind) (StatusViewer, error) {
	switch kind {
	case extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment").GroupKind(),
		appsv1.SchemeGroupVersion.WithKind("Deployment").GroupKind():
		return &DeploymentStatusViewer{}, nil
	case extensionsv1beta1.SchemeGroupVersion.WithKind("DaemonSet").GroupKind(),
		appsv1.SchemeGroupVersion.WithKind("DaemonSet").GroupKind():
		return &DaemonSetStatusViewer{}, nil
	case appsv1.SchemeGroupVersion.WithKind("StatefulSet").GroupKind():
		return &StatefulSetStatusViewer{}, nil
	}
	return nil, fmt.Errorf("no status viewer has been implemented for %v", kind)
}
621277
func (c *Client) GetStatus() (result Status, err error) {
	call := c.object.Call(dbusInterface+".GetStatus", 0)
	err = call.Err
	if err != nil {
		return
	}

	result = NewStatus(call.Body)

	return
}
612383
func GetStatusFromErr(err error) int {
	obj, ok := err.(*UnexpectedResponseError)
	if !ok {
		return -1
	}
	return obj.Actual
}
1306090
func (s *DocumentDescription) SetStatusInformation(v string) *DocumentDescription {
	s.StatusInformation = &v
	return s
}
1165726
func (a API) SetAgentStatus(args params.SetStatus) error {
	var result params.ErrorResults
	err := a.facade.FacadeCall("SetAgentStatus", args, &result)
	if err != nil {
		return err
	}
	return result.Combine()
}
70673
func (c UnitFacadeClient) SetStatus(status string, fullIDs ...string) ([]payload.Result, error) {
	ids, err := c.lookUp(fullIDs)
	if err != nil {
		return nil, errors.Trace(err)
	}
	args := internal.IDs2SetStatusArgs(ids, status)

	var rs params.PayloadResults
	if err := c.FacadeCall("SetStatus", &args, &rs); err != nil {
		return nil, err
	}

	return api2results(rs)
}
716603
func (d *PendingDeployment) UpdateStatus(status string) {
	d.mutex.Lock()
	defer d.mutex.Unlock()
	d.status.Set(status)
}