github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/api/types/swarm/node.go (about)

     1  package swarm
     2  
     3  // Node represents a node.
     4  type Node struct {
     5  	ID string
     6  	Meta
     7  	// Spec defines the desired state of the node as specified by the user.
     8  	// The system will honor this and will *never* modify it.
     9  	Spec NodeSpec `json:",omitempty"`
    10  	// Description encapsulates the properties of the Node as reported by the
    11  	// agent.
    12  	Description NodeDescription `json:",omitempty"`
    13  	// Status provides the current status of the node, as seen by the manager.
    14  	Status NodeStatus `json:",omitempty"`
    15  	// ManagerStatus provides the current status of the node's manager
    16  	// component, if the node is a manager.
    17  	ManagerStatus *ManagerStatus `json:",omitempty"`
    18  }
    19  
    20  // NodeSpec represents the spec of a node.
    21  type NodeSpec struct {
    22  	Annotations
    23  	Role         NodeRole         `json:",omitempty"`
    24  	Availability NodeAvailability `json:",omitempty"`
    25  }
    26  
    27  // NodeRole represents the role of a node.
    28  type NodeRole string
    29  
    30  const (
    31  	// NodeRoleWorker WORKER
    32  	NodeRoleWorker NodeRole = "worker"
    33  	// NodeRoleManager MANAGER
    34  	NodeRoleManager NodeRole = "manager"
    35  )
    36  
    37  // NodeAvailability represents the availability of a node.
    38  type NodeAvailability string
    39  
    40  const (
    41  	// NodeAvailabilityActive ACTIVE
    42  	NodeAvailabilityActive NodeAvailability = "active"
    43  	// NodeAvailabilityPause PAUSE
    44  	NodeAvailabilityPause NodeAvailability = "pause"
    45  	// NodeAvailabilityDrain DRAIN
    46  	NodeAvailabilityDrain NodeAvailability = "drain"
    47  )
    48  
    49  // NodeDescription represents the description of a node.
    50  type NodeDescription struct {
    51  	Hostname  string            `json:",omitempty"`
    52  	Platform  Platform          `json:",omitempty"`
    53  	Resources Resources         `json:",omitempty"`
    54  	Engine    EngineDescription `json:",omitempty"`
    55  }
    56  
    57  // Platform represents the platfrom (Arch/OS).
    58  type Platform struct {
    59  	Architecture string `json:",omitempty"`
    60  	OS           string `json:",omitempty"`
    61  }
    62  
    63  // EngineDescription represents the description of an engine.
    64  type EngineDescription struct {
    65  	EngineVersion string              `json:",omitempty"`
    66  	Labels        map[string]string   `json:",omitempty"`
    67  	Plugins       []PluginDescription `json:",omitempty"`
    68  }
    69  
    70  // PluginDescription represents the description of an engine plugin.
    71  type PluginDescription struct {
    72  	Type string `json:",omitempty"`
    73  	Name string `json:",omitempty"`
    74  }
    75  
    76  // NodeStatus represents the status of a node.
    77  type NodeStatus struct {
    78  	State   NodeState `json:",omitempty"`
    79  	Message string    `json:",omitempty"`
    80  }
    81  
    82  // Reachability represents the reachability of a node.
    83  type Reachability string
    84  
    85  const (
    86  	// ReachabilityUnknown UNKNOWN
    87  	ReachabilityUnknown Reachability = "unknown"
    88  	// ReachabilityUnreachable UNREACHABLE
    89  	ReachabilityUnreachable Reachability = "unreachable"
    90  	// ReachabilityReachable REACHABLE
    91  	ReachabilityReachable Reachability = "reachable"
    92  )
    93  
    94  // ManagerStatus represents the status of a manager.
    95  type ManagerStatus struct {
    96  	Leader       bool         `json:",omitempty"`
    97  	Reachability Reachability `json:",omitempty"`
    98  	Addr         string       `json:",omitempty"`
    99  }
   100  
   101  // NodeState represents the state of a node.
   102  type NodeState string
   103  
   104  const (
   105  	// NodeStateUnknown UNKNOWN
   106  	NodeStateUnknown NodeState = "unknown"
   107  	// NodeStateDown DOWN
   108  	NodeStateDown NodeState = "down"
   109  	// NodeStateReady READY
   110  	NodeStateReady NodeState = "ready"
   111  	// NodeStateDisconnected DISCONNECTED
   112  	NodeStateDisconnected NodeState = "disconnected"
   113  )