github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/apiserver/params/status.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package params 5 6 // TODO(ericsnow) Eliminate the juju-related imports. 7 8 import ( 9 "time" 10 11 "gopkg.in/juju/charm.v6-unstable" 12 13 "github.com/juju/juju/instance" 14 "github.com/juju/juju/state/multiwatcher" 15 "github.com/juju/juju/status" 16 ) 17 18 // StatusParams holds parameters for the Status call. 19 type StatusParams struct { 20 Patterns []string 21 } 22 23 // TODO(ericsnow) Add FullStatusResult. 24 25 // FullStatus holds information about the status of a juju model. 26 type FullStatus struct { 27 ModelName string 28 AvailableVersion string 29 Machines map[string]MachineStatus 30 Services map[string]ServiceStatus 31 Relations []RelationStatus 32 } 33 34 // MachineStatus holds status info about a machine. 35 type MachineStatus struct { 36 AgentStatus DetailedStatus 37 InstanceStatus DetailedStatus 38 39 DNSName string 40 InstanceId instance.Id 41 Series string 42 Id string 43 Containers map[string]MachineStatus 44 Hardware string 45 Jobs []multiwatcher.MachineJob 46 HasVote bool 47 WantsVote bool 48 } 49 50 // ServiceStatus holds status info about a service. 51 type ServiceStatus struct { 52 Err error 53 Charm string 54 Exposed bool 55 Life string 56 Relations map[string][]string 57 CanUpgradeTo string 58 SubordinateTo []string 59 Units map[string]UnitStatus 60 MeterStatuses map[string]MeterStatus 61 Status DetailedStatus 62 } 63 64 // MeterStatus represents the meter status of a unit. 65 type MeterStatus struct { 66 Color string 67 Message string 68 } 69 70 // UnitStatus holds status info about a unit. 71 type UnitStatus struct { 72 // AgentStatus holds the status for a unit's agent. 73 AgentStatus DetailedStatus 74 75 // WorkloadStatus holds the status for a unit's workload 76 WorkloadStatus DetailedStatus 77 78 Machine string 79 OpenedPorts []string 80 PublicAddress string 81 Charm string 82 Subordinates map[string]UnitStatus 83 } 84 85 // RelationStatus holds status info about a relation. 86 type RelationStatus struct { 87 Id int 88 Key string 89 Interface string 90 Scope charm.RelationScope 91 Endpoints []EndpointStatus 92 } 93 94 // EndpointStatus holds status info about a single endpoint 95 type EndpointStatus struct { 96 ServiceName string 97 Name string 98 Role charm.RelationRole 99 Subordinate bool 100 } 101 102 // TODO(ericsnow) Eliminate the String method. 103 104 func (epStatus *EndpointStatus) String() string { 105 return epStatus.ServiceName + ":" + epStatus.Name 106 } 107 108 // DetailedStatus holds status info about a machine or unit agent. 109 type DetailedStatus struct { 110 Status status.Status 111 Info string 112 Data map[string]interface{} 113 Since *time.Time 114 Kind HistoryKind 115 Version string 116 Life string 117 Err error 118 } 119 120 // StatusHistoryArgs holds the parameters to filter a status history query. 121 type StatusHistoryArgs struct { 122 Kind HistoryKind 123 Size int 124 Name string 125 } 126 127 // StatusHistoryResults holds a slice of statuses. 128 type StatusHistoryResults struct { 129 Statuses []DetailedStatus 130 } 131 132 // StatusHistoryPruneArgs holds arguments for status history 133 // prunning process. 134 type StatusHistoryPruneArgs struct { 135 MaxLogsPerEntity int 136 } 137 138 // StatusResult holds an entity status, extra information, or an 139 // error. 140 type StatusResult struct { 141 Error *Error 142 Id string 143 Life Life 144 Status status.Status 145 Info string 146 Data map[string]interface{} 147 Since *time.Time 148 } 149 150 // StatusResults holds multiple status results. 151 type StatusResults struct { 152 Results []StatusResult 153 } 154 155 // ServiceStatusResult holds results for a service Full Status 156 type ServiceStatusResult struct { 157 Service StatusResult 158 Units map[string]StatusResult 159 Error *Error 160 } 161 162 // ServiceStatusResults holds multiple StatusResult. 163 type ServiceStatusResults struct { 164 Results []ServiceStatusResult 165 } 166 167 // HistoryKind represents the possible types of 168 // status history entries. 169 type HistoryKind string 170 171 const ( 172 // KindUnit represents agent and workload combined. 173 KindUnit HistoryKind = "unit" 174 // KindUnitAgent represent a unit agent status history entry. 175 KindUnitAgent HistoryKind = "juju-unit" 176 // KindWorkload represents a charm workload status history entry. 177 KindWorkload HistoryKind = "workload" 178 // KindMachineInstance represents an entry for a machine instance. 179 KindMachineInstance = "machine" 180 // KindMachine represents an entry for a machine agent. 181 KindMachine = "juju-machine" 182 // KindContainerInstance represents an entry for a container instance. 183 KindContainerInstance = "container" 184 // KindContainer represents an entry for a container agent. 185 KindContainer = "juju-container" 186 ) 187 188 // Life describes the lifecycle state of an entity ("alive", "dying" or "dead"). 189 type Life multiwatcher.Life 190 191 const ( 192 Alive Life = "alive" 193 Dying Life = "dying" 194 Dead Life = "dead" 195 )