launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/state/api/params/constants.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  // Life describes the lifecycle state of an entity ("alive", "dying"
     7  // or "dead").
     8  
     9  type Life string
    10  
    11  const (
    12  	Alive Life = "alive"
    13  	Dying Life = "dying"
    14  	Dead  Life = "dead"
    15  )
    16  
    17  // MachineJob values define responsibilities that machines may be
    18  // expected to fulfil.
    19  type MachineJob string
    20  
    21  const (
    22  	JobHostUnits     MachineJob = "JobHostUnits"
    23  	JobManageEnviron MachineJob = "JobManageEnviron"
    24  	// Deprecated in 1.18
    25  	JobManageState MachineJob = "JobManageState"
    26  )
    27  
    28  // NeedsState returns true if the job requires a state connection.
    29  func (job MachineJob) NeedsState() bool {
    30  	return job == JobManageEnviron
    31  }
    32  
    33  // ResolvedMode describes the way state transition errors
    34  // are resolved.
    35  type ResolvedMode string
    36  
    37  const (
    38  	ResolvedNone       ResolvedMode = ""
    39  	ResolvedRetryHooks ResolvedMode = "retry-hooks"
    40  	ResolvedNoHooks    ResolvedMode = "no-hooks"
    41  )
    42  
    43  // Status represents the status of an entity.
    44  // It could be a unit, machine or its agent.
    45  type Status string
    46  
    47  const (
    48  	// The entity is not yet participating in the environment.
    49  	StatusPending Status = "pending"
    50  
    51  	// The unit has performed initial setup and is adapting itself to
    52  	// the environment. Not applicable to machines.
    53  	StatusInstalled Status = "installed"
    54  
    55  	// The entity is actively participating in the environment.
    56  	StatusStarted Status = "started"
    57  
    58  	// The entity's agent will perform no further action, other than
    59  	// to set the unit to Dead at a suitable moment.
    60  	StatusStopped Status = "stopped"
    61  
    62  	// The entity requires human intervention in order to operate
    63  	// correctly.
    64  	StatusError Status = "error"
    65  
    66  	// The entity ought to be signalling activity, but it cannot be
    67  	// detected.
    68  	StatusDown Status = "down"
    69  )
    70  
    71  // Valid returns true if status has a known value.
    72  func (status Status) Valid() bool {
    73  	switch status {
    74  	case
    75  		StatusPending,
    76  		StatusInstalled,
    77  		StatusStarted,
    78  		StatusStopped,
    79  		StatusError,
    80  		StatusDown:
    81  	default:
    82  		return false
    83  	}
    84  	return true
    85  }