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