github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/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/core/instance" 12 "github.com/juju/juju/core/life" 13 "github.com/juju/juju/core/model" 14 "github.com/juju/juju/core/relation" 15 ) 16 17 // StatusParams holds parameters for the Status call. 18 type StatusParams struct { 19 Patterns []string `json:"patterns"` 20 IncludeStorage bool `json:"include-storage,omitempty"` 21 } 22 23 // FullStatus holds information about the status of a juju model. 24 type FullStatus struct { 25 Model ModelStatusInfo `json:"model"` 26 Machines map[string]MachineStatus `json:"machines"` 27 Applications map[string]ApplicationStatus `json:"applications"` 28 RemoteApplications map[string]RemoteApplicationStatus `json:"remote-applications"` 29 Offers map[string]ApplicationOfferStatus `json:"offers"` 30 Relations []RelationStatus `json:"relations"` 31 ControllerTimestamp *time.Time `json:"controller-timestamp"` 32 Branches map[string]BranchStatus `json:"branches"` 33 Storage []StorageDetails `json:"storage,omitempty"` 34 Filesystems []FilesystemDetails `json:"filesystems,omitempty"` 35 Volumes []VolumeDetails `json:"volumes,omitempty"` 36 } 37 38 // IsEmpty checks all collections on FullStatus to determine if the status is empty. 39 // Note that only the collections are checked here as Model information will always be populated. 40 func (fs *FullStatus) IsEmpty() bool { 41 return len(fs.Applications) == 0 && 42 len(fs.Machines) == 0 && 43 len(fs.Offers) == 0 && 44 len(fs.RemoteApplications) == 0 && 45 len(fs.Relations) == 0 46 } 47 48 // ModelStatusInfo holds status information about the model itself. 49 type ModelStatusInfo struct { 50 Name string `json:"name"` 51 Type string `json:"type"` 52 CloudTag string `json:"cloud-tag"` 53 CloudRegion string `json:"region,omitempty"` 54 Version string `json:"version"` 55 AvailableVersion string `json:"available-version"` 56 ModelStatus DetailedStatus `json:"model-status"` 57 MeterStatus MeterStatus `json:"meter-status"` 58 SLA string `json:"sla"` 59 } 60 61 // NetworkInterface holds a /etc/network/interfaces-type data and the 62 // space name for any device with at least one associated IP address. 63 type NetworkInterface struct { 64 // IPAddresses holds the IP addresses bound to this machine. 65 IPAddresses []string `json:"ip-addresses"` 66 MACAddress string `json:"mac-address"` 67 Gateway string `json:"gateway,omitempty"` 68 DNSNameservers []string `json:"dns-nameservers,omitempty"` 69 70 // Space holds the name of a space in which this devices IP addr's 71 // subnet belongs. 72 Space string `json:"space,omitempty"` 73 74 // Is this interface up? 75 IsUp bool `json:"is-up"` 76 } 77 78 // MachineStatus holds status info about a machine. 79 type MachineStatus struct { 80 AgentStatus DetailedStatus `json:"agent-status"` 81 InstanceStatus DetailedStatus `json:"instance-status"` 82 ModificationStatus DetailedStatus `json:"modification-status"` 83 84 Hostname string `json:"hostname,omitempty"` 85 DNSName string `json:"dns-name"` 86 87 // IPAddresses holds the IP addresses known for this machine. It is 88 // here for backwards compatibility. It should be similar to its 89 // namesakes in NetworkInterfaces, but may also include any 90 // public/floating IP addresses not actually bound to the machine but 91 // known to the provider. 92 IPAddresses []string `json:"ip-addresses,omitempty"` 93 94 // InstanceId holds the unique identifier for this machine, based on 95 // what is supplied by the provider. 96 InstanceId instance.Id `json:"instance-id"` 97 98 // DisplayName is a human-readable name for this machine. 99 DisplayName string `json:"display-name"` 100 101 // Base holds the details of the operating system release installed on 102 // this machine. 103 Base Base `json:"base"` 104 105 // Id is the Juju identifier for this machine in this model. 106 Id string `json:"id"` 107 108 // NetworkInterfaces holds a map of NetworkInterface for this machine. 109 NetworkInterfaces map[string]NetworkInterface `json:"network-interfaces,omitempty"` 110 111 // Containers holds the MachineStatus of any containers hosted on this 112 // machine. 113 Containers map[string]MachineStatus `json:"containers"` 114 115 // Constraints holds a string of space-separated key=value pairs for 116 // each constraint datum. 117 Constraints string `json:"constraints"` 118 119 // Hardware holds a string of space-separated key=value pairs for each 120 // hardware specification datum. 121 Hardware string `json:"hardware"` 122 123 Jobs []model.MachineJob `json:"jobs"` 124 HasVote bool `json:"has-vote"` 125 WantsVote bool `json:"wants-vote"` 126 127 // LXDProfiles holds all the machines current LXD profiles that have 128 // been applied to the machine 129 LXDProfiles map[string]LXDProfile `json:"lxd-profiles,omitempty"` 130 131 // PrimaryControllerMachine indicates whether this machine has a primary mongo instance in replicaset and, 132 // // thus, can be considered a primary controller machine in HA setup. 133 PrimaryControllerMachine *bool `json:"primary-controller-machine,omitempty"` 134 } 135 136 // LXDProfile holds status info about a LXDProfile 137 type LXDProfile struct { 138 Config map[string]string `json:"config"` 139 Description string `json:"description"` 140 Devices map[string]map[string]string `json:"devices"` 141 } 142 143 // ApplicationStatus holds status info about an application. 144 type ApplicationStatus struct { 145 Err *Error `json:"err,omitempty"` 146 Charm string `json:"charm"` 147 CharmVersion string `json:"charm-version"` 148 CharmProfile string `json:"charm-profile"` 149 CharmChannel string `json:"charm-channel,omitempty"` 150 Base Base `json:"base"` 151 Exposed bool `json:"exposed"` 152 ExposedEndpoints map[string]ExposedEndpoint `json:"exposed-endpoints,omitempty"` 153 Life life.Value `json:"life"` 154 Relations map[string][]string `json:"relations"` 155 CanUpgradeTo string `json:"can-upgrade-to"` 156 SubordinateTo []string `json:"subordinate-to"` 157 Units map[string]UnitStatus `json:"units"` 158 MeterStatuses map[string]MeterStatus `json:"meter-statuses"` 159 Status DetailedStatus `json:"status"` 160 WorkloadVersion string `json:"workload-version"` 161 EndpointBindings map[string]string `json:"endpoint-bindings"` 162 163 // The following are for CAAS models. 164 Scale int `json:"int,omitempty"` 165 ProviderId string `json:"provider-id,omitempty"` 166 PublicAddress string `json:"public-address"` 167 } 168 169 // RemoteApplicationStatus holds status info about a remote application. 170 type RemoteApplicationStatus struct { 171 Err *Error `json:"err,omitempty"` 172 OfferURL string `json:"offer-url"` 173 OfferName string `json:"offer-name"` 174 Endpoints []RemoteEndpoint `json:"endpoints"` 175 Life life.Value `json:"life"` 176 Relations map[string][]string `json:"relations"` 177 Status DetailedStatus `json:"status"` 178 } 179 180 // ApplicationOfferStatus holds status info about an application offer. 181 type ApplicationOfferStatus struct { 182 Err *Error `json:"err,omitempty"` 183 OfferName string `json:"offer-name"` 184 ApplicationName string `json:"application-name"` 185 CharmURL string `json:"charm"` 186 Endpoints map[string]RemoteEndpoint `json:"endpoints"` 187 ActiveConnectedCount int `json:"active-connected-count"` 188 TotalConnectedCount int `json:"total-connected-count"` 189 } 190 191 // MeterStatus represents the meter status of a unit. 192 type MeterStatus struct { 193 Color string `json:"color"` 194 Message string `json:"message"` 195 } 196 197 // UnitStatus holds status info about a unit. 198 type UnitStatus struct { 199 // AgentStatus holds the status for a unit's agent. 200 AgentStatus DetailedStatus `json:"agent-status"` 201 202 // WorkloadStatus holds the status for a unit's workload. 203 WorkloadStatus DetailedStatus `json:"workload-status"` 204 WorkloadVersion string `json:"workload-version"` 205 206 Machine string `json:"machine"` 207 OpenedPorts []string `json:"opened-ports"` 208 PublicAddress string `json:"public-address"` 209 Charm string `json:"charm"` 210 Subordinates map[string]UnitStatus `json:"subordinates"` 211 Leader bool `json:"leader,omitempty"` 212 213 // The following are for CAAS models. 214 ProviderId string `json:"provider-id,omitempty"` 215 Address string `json:"address,omitempty"` 216 } 217 218 // RelationStatus holds status info about a relation. 219 type RelationStatus struct { 220 Id int `json:"id"` 221 Key string `json:"key"` 222 Interface string `json:"interface"` 223 Scope string `json:"scope"` 224 Endpoints []EndpointStatus `json:"endpoints"` 225 Status DetailedStatus `json:"status"` 226 } 227 228 // EndpointStatus holds status info about a single endpoint. 229 type EndpointStatus struct { 230 ApplicationName string `json:"application"` 231 Name string `json:"name"` 232 Role string `json:"role"` 233 Subordinate bool `json:"subordinate"` 234 } 235 236 // TODO(ericsnow) Eliminate the String method. 237 238 func (epStatus *EndpointStatus) String() string { 239 return epStatus.ApplicationName + ":" + epStatus.Name 240 } 241 242 // DetailedStatus holds status info about a machine or unit agent. 243 type DetailedStatus struct { 244 Status string `json:"status"` 245 Info string `json:"info"` 246 Data map[string]interface{} `json:"data"` 247 Since *time.Time `json:"since"` 248 Kind string `json:"kind"` 249 Version string `json:"version"` 250 Life life.Value `json:"life"` 251 Err *Error `json:"err,omitempty"` 252 } 253 254 // History holds many DetailedStatus. 255 type History struct { 256 Statuses []DetailedStatus `json:"statuses"` 257 Error *Error `json:"error,omitempty"` 258 } 259 260 // StatusHistoryFilter holds arguments that can be use to filter a status history backlog. 261 type StatusHistoryFilter struct { 262 Size int `json:"size"` 263 Date *time.Time `json:"date"` 264 Delta *time.Duration `json:"delta"` 265 Exclude []string `json:"exclude"` 266 } 267 268 // StatusHistoryRequest holds the parameters to filter a status history query. 269 type StatusHistoryRequest struct { 270 Kind string `json:"historyKind"` 271 Size int `json:"size"` 272 Filter StatusHistoryFilter `json:"filter"` 273 Tag string `json:"tag"` 274 } 275 276 // StatusHistoryRequests holds a slice of StatusHistoryArgs. 277 type StatusHistoryRequests struct { 278 Requests []StatusHistoryRequest `json:"requests"` 279 } 280 281 // StatusHistoryResult holds a slice of statuses. 282 type StatusHistoryResult struct { 283 History History `json:"history"` 284 Error *Error `json:"error,omitempty"` 285 } 286 287 // StatusHistoryResults holds a slice of StatusHistoryResult. 288 type StatusHistoryResults struct { 289 Results []StatusHistoryResult `json:"results"` 290 } 291 292 // StatusHistoryPruneArgs holds arguments for status history 293 // prunning process. 294 type StatusHistoryPruneArgs struct { 295 MaxHistoryTime time.Duration `json:"max-history-time"` 296 MaxHistoryMB int `json:"max-history-mb"` 297 } 298 299 // StatusResult holds an entity status, extra information, or an 300 // error. 301 type StatusResult struct { 302 Error *Error `json:"error,omitempty"` 303 Id string `json:"id"` 304 Life life.Value `json:"life"` 305 Status string `json:"status"` 306 Info string `json:"info"` 307 Data map[string]interface{} `json:"data"` 308 Since *time.Time `json:"since"` 309 } 310 311 // StatusResults holds multiple status results. 312 type StatusResults struct { 313 Results []StatusResult `json:"results"` 314 } 315 316 // ApplicationStatusResult holds results for an application Full Status. 317 type ApplicationStatusResult struct { 318 Application StatusResult `json:"application"` 319 Units map[string]StatusResult `json:"units"` 320 Error *Error `json:"error,omitempty"` 321 } 322 323 // ApplicationStatusResults holds multiple StatusResult. 324 type ApplicationStatusResults struct { 325 Results []ApplicationStatusResult `json:"results"` 326 } 327 328 // RelationStatusValue describes the status of a relation. 329 type RelationStatusValue relation.Status 330 331 const ( 332 Joined RelationStatusValue = "joined" 333 Suspended RelationStatusValue = "suspended" 334 Broken RelationStatusValue = "broken" 335 ) 336 337 // BranchStatus holds the results for an branch Full Status. 338 type BranchStatus struct { 339 AssignedUnits map[string][]string `json:"assigned-units"` 340 Created int64 `json:"created"` 341 CreatedBy string `json:"created-by"` 342 }