Beispiel #1
0
func (s *UnitStatusSuite) checkUntouched(c *gc.C) {
	agent, workload := common.UnitStatus(s.unit)
	c.Check(agent.Status, jc.DeepEquals, s.unit.agentStatus)
	c.Check(agent.Err, jc.ErrorIsNil)
	c.Check(workload.Status, jc.DeepEquals, s.unit.status)
	c.Check(workload.Err, jc.ErrorIsNil)
}
Beispiel #2
0
func (s *UnitStatusSuite) TestErrors(c *gc.C) {
	s.unit.agentStatusErr = errors.New("agent status error")
	s.unit.statusErr = errors.New("status error")

	agent, workload := common.UnitStatus(s.unit)
	c.Check(agent.Err, gc.ErrorMatches, "agent status error")
	c.Check(workload.Err, gc.ErrorMatches, "status error")
}
Beispiel #3
0
func checkUnitAgentStatus(unit PrecheckUnit) error {
	statusData, _ := common.UnitStatus(unit)
	if statusData.Err != nil {
		return errors.Annotatef(statusData.Err, "retrieving unit %s status", unit.Name())
	}
	agentStatus := statusData.Status.Status
	if agentStatus != status.Idle {
		return newStatusError("unit %s not idle", unit.Name(), agentStatus)
	}
	return nil
}
Beispiel #4
0
// processUnit retrieves version and status information for the given unit.
func processUnit(unit *state.Unit) (agentStatus, workloadStatus params.DetailedStatus) {
	agent, workload := common.UnitStatus(unit)
	populateStatusFromStatusInfoAndErr(&agentStatus, agent.Status, agent.Err)
	populateStatusFromStatusInfoAndErr(&workloadStatus, workload.Status, workload.Err)

	agentStatus.Life = processLife(unit)

	if t, err := unit.AgentTools(); err == nil {
		agentStatus.Version = t.Version.Number.String()
	}
	return
}
Beispiel #5
0
func (s *UnitStatusSuite) TestLost(c *gc.C) {
	s.unit.presence = false
	agent, workload := common.UnitStatus(s.unit)
	c.Check(agent.Status, jc.DeepEquals, status.StatusInfo{
		Status:  status.Lost,
		Message: "agent is not communicating with the server",
	})
	c.Check(agent.Err, jc.ErrorIsNil)
	c.Check(workload.Status, jc.DeepEquals, status.StatusInfo{
		Status:  status.Unknown,
		Message: "agent lost, see 'juju show-status-log foo/2'",
	})
	c.Check(workload.Err, jc.ErrorIsNil)
}