~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/migration/precheck.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        AgentTools() (*tools.Tools, error)
50
50
        Life() state.Life
51
51
        Status() (status.StatusInfo, error)
 
52
        AgentPresence() (bool, error)
52
53
        InstanceStatus() (status.StatusInfo, error)
53
54
        ShouldRebootOrShutdown() (state.RebootAction, error)
54
55
}
214
215
 
215
216
                if statusInfo, err := machine.InstanceStatus(); err != nil {
216
217
                        return errors.Annotatef(err, "retrieving machine %s instance status", machine.Id())
217
 
                } else if statusInfo.Status != status.StatusRunning {
 
218
                } else if statusInfo.Status != status.Running {
218
219
                        return newStatusError("machine %s not running", machine.Id(), statusInfo.Status)
219
220
                }
220
221
 
221
 
                if statusInfo, err := machine.Status(); err != nil {
 
222
                if statusInfo, err := common.MachineStatus(machine); err != nil {
222
223
                        return errors.Annotatef(err, "retrieving machine %s status", machine.Id())
223
 
                } else if statusInfo.Status != status.StatusStarted {
224
 
                        return newStatusError("machine %s not started", machine.Id(), statusInfo.Status)
 
224
                } else if statusInfo.Status != status.Started {
 
225
                        return newStatusError("machine %s agent not functioning at this time",
 
226
                                machine.Id(), statusInfo.Status)
225
227
                }
226
228
 
227
229
                if rebootAction, err := machine.ShouldRebootOrShutdown(); err != nil {
296
298
                return errors.Annotatef(statusData.Err, "retrieving unit %s status", unit.Name())
297
299
        }
298
300
        agentStatus := statusData.Status.Status
299
 
        if agentStatus != status.StatusIdle {
 
301
        if agentStatus != status.Idle {
300
302
                return newStatusError("unit %s not idle", unit.Name(), agentStatus)
301
303
        }
302
304
        return nil
321
323
 
322
324
func newStatusError(format, id string, s status.Status) error {
323
325
        msg := fmt.Sprintf(format, id)
324
 
        if s != status.StatusEmpty {
 
326
        if s != status.Empty {
325
327
                msg += fmt.Sprintf(" (%s)", s)
326
328
        }
327
329
        return errors.New(msg)