github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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 "github.com/juju/juju/instance" 12 "github.com/juju/juju/state/multiwatcher" 13 ) 14 15 // StatusParams holds parameters for the Status call. 16 type StatusParams struct { 17 Patterns []string `json:"patterns"` 18 } 19 20 // TODO(ericsnow) Add FullStatusResult. 21 22 // FullStatus holds information about the status of a juju model. 23 type FullStatus struct { 24 Model ModelStatusInfo `json:"model"` 25 Machines map[string]MachineStatus `json:"machines"` 26 Applications map[string]ApplicationStatus `json:"applications"` 27 Relations []RelationStatus `json:"relations"` 28 } 29 30 // ModelStatusInfo holds status information about the model itself. 31 type ModelStatusInfo struct { 32 Name string `json:"name"` 33 CloudTag string `json:"cloud-tag"` 34 CloudRegion string `json:"region,omitempty"` 35 Version string `json:"version"` 36 AvailableVersion string `json:"available-version"` 37 Migration string `json:"migration,omitempty"` 38 } 39 40 // MachineStatus holds status info about a machine. 41 type MachineStatus struct { 42 AgentStatus DetailedStatus `json:"agent-status"` 43 InstanceStatus DetailedStatus `json:"instance-status"` 44 45 DNSName string `json:"dns-name"` 46 47 // IPAddresses holds the IP addresses bound to this machine. 48 IPAddresses []string `json:"ip-addresses"` 49 50 // InstanceId holds the unique identifier for this machine, based on 51 // what is supplied by the provider. 52 InstanceId instance.Id `json:"instance-id"` 53 54 // Series holds the name of the operating system release installed on 55 // this machine. 56 Series string `json:"series"` 57 58 // Id is the Juju identifier for this machine in this model. 59 Id string `json:"id"` 60 61 // Containers holds the MachineStatus of any containers hosted on this 62 // machine. 63 Containers map[string]MachineStatus `json:"containers"` 64 65 // Hardware holds a string of space-separated key=value pairs of 66 // hardware specification datum. 67 Hardware string `json:"hardware"` 68 69 Jobs []multiwatcher.MachineJob `json:"jobs"` 70 HasVote bool `json:"has-vote"` 71 WantsVote bool `json:"wants-vote"` 72 } 73 74 // ApplicationStatus holds status info about an application. 75 type ApplicationStatus struct { 76 Err error `json:"err,omitempty"` 77 Charm string `json:"charm"` 78 Series string `json:"series"` 79 Exposed bool `json:"exposed"` 80 Life string `json:"life"` 81 Relations map[string][]string `json:"relations"` 82 CanUpgradeTo string `json:"can-upgrade-to"` 83 SubordinateTo []string `json:"subordinate-to"` 84 Units map[string]UnitStatus `json:"units"` 85 MeterStatuses map[string]MeterStatus `json:"meter-statuses"` 86 Status DetailedStatus `json:"status"` 87 WorkloadVersion string `json:"workload-version"` 88 } 89 90 // MeterStatus represents the meter status of a unit. 91 type MeterStatus struct { 92 Color string `json:"color"` 93 Message string `json:"message"` 94 } 95 96 // UnitStatus holds status info about a unit. 97 type UnitStatus struct { 98 // AgentStatus holds the status for a unit's agent. 99 AgentStatus DetailedStatus `json:"agent-status"` 100 101 // WorkloadStatus holds the status for a unit's workload. 102 WorkloadStatus DetailedStatus `json:"workload-status"` 103 WorkloadVersion string `json:"workload-version"` 104 105 Machine string `json:"machine"` 106 OpenedPorts []string `json:"opened-ports"` 107 PublicAddress string `json:"public-address"` 108 Charm string `json:"charm"` 109 Subordinates map[string]UnitStatus `json:"subordinates"` 110 Leader bool `json:"leader,omitempty"` 111 } 112 113 // RelationStatus holds status info about a relation. 114 type RelationStatus struct { 115 Id int `json:"id"` 116 Key string `json:"key"` 117 Interface string `json:"interface"` 118 Scope string `json:"scope"` 119 Endpoints []EndpointStatus `json:"endpoints"` 120 } 121 122 // EndpointStatus holds status info about a single endpoint. 123 type EndpointStatus struct { 124 ApplicationName string `json:"application"` 125 Name string `json:"name"` 126 Role string `json:"role"` 127 Subordinate bool `json:"subordinate"` 128 } 129 130 // TODO(ericsnow) Eliminate the String method. 131 132 func (epStatus *EndpointStatus) String() string { 133 return epStatus.ApplicationName + ":" + epStatus.Name 134 } 135 136 // DetailedStatus holds status info about a machine or unit agent. 137 type DetailedStatus struct { 138 Status string `json:"status"` 139 Info string `json:"info"` 140 Data map[string]interface{} `json:"data"` 141 Since *time.Time `json:"since"` 142 Kind string `json:"kind"` 143 Version string `json:"version"` 144 Life string `json:"life"` 145 Err error `json:"err,omitempty"` 146 } 147 148 // History holds many DetailedStatus. 149 type History struct { 150 Statuses []DetailedStatus `json:"statuses"` 151 Error *Error `json:"error,omitempty"` 152 } 153 154 // StatusHistoryFilter holds arguments that can be use to filter a status history backlog. 155 type StatusHistoryFilter struct { 156 Size int `json:"size"` 157 Date *time.Time `json:"date"` 158 Delta *time.Duration `json:"delta"` 159 } 160 161 // StatusHistoryRequest holds the parameters to filter a status history query. 162 type StatusHistoryRequest struct { 163 Kind string `json:"historyKind"` 164 Size int `json:"size"` 165 Filter StatusHistoryFilter `json:"filter"` 166 Tag string `json:"tag"` 167 } 168 169 // StatusHistoryRequests holds a slice of StatusHistoryArgs. 170 type StatusHistoryRequests struct { 171 Requests []StatusHistoryRequest `json:"requests"` 172 } 173 174 // StatusHistoryResult holds a slice of statuses. 175 type StatusHistoryResult struct { 176 History History `json:"history"` 177 Error *Error `json:"error,omitempty"` 178 } 179 180 // StatusHistoryResults holds a slice of StatusHistoryResult. 181 type StatusHistoryResults struct { 182 Results []StatusHistoryResult `json:"results"` 183 } 184 185 // StatusHistoryPruneArgs holds arguments for status history 186 // prunning process. 187 type StatusHistoryPruneArgs struct { 188 MaxHistoryTime time.Duration `json:"max-history-time"` 189 MaxHistoryMB int `json:"max-history-mb"` 190 } 191 192 // StatusResult holds an entity status, extra information, or an 193 // error. 194 type StatusResult struct { 195 Error *Error `json:"error,omitempty"` 196 Id string `json:"id"` 197 Life Life `json:"life"` 198 Status string `json:"status"` 199 Info string `json:"info"` 200 Data map[string]interface{} `json:"data"` 201 Since *time.Time `json:"since"` 202 } 203 204 // StatusResults holds multiple status results. 205 type StatusResults struct { 206 Results []StatusResult `json:"results"` 207 } 208 209 // ApplicationStatusResult holds results for an application Full Status. 210 type ApplicationStatusResult struct { 211 Application StatusResult `json:"application"` 212 Units map[string]StatusResult `json:"units"` 213 Error *Error `json:"error,omitempty"` 214 } 215 216 // ApplicationStatusResults holds multiple StatusResult. 217 type ApplicationStatusResults struct { 218 Results []ApplicationStatusResult `json:"results"` 219 } 220 221 // Life describes the lifecycle state of an entity ("alive", "dying" or "dead"). 222 type Life multiwatcher.Life 223 224 const ( 225 Alive Life = "alive" 226 Dying Life = "dying" 227 Dead Life = "dead" 228 )