~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/params/status.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        Cloud            string `json:"cloud"`
 
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
        InstanceId instance.Id               `json:"instance-id"`
 
47
        Series     string                    `json:"series"`
 
48
        Id         string                    `json:"id"`
 
49
        Containers map[string]MachineStatus  `json:"containers"`
 
50
        Hardware   string                    `json:"hardware"`
 
51
        Jobs       []multiwatcher.MachineJob `json:"jobs"`
 
52
        HasVote    bool                      `json:"has-vote"`
 
53
        WantsVote  bool                      `json:"wants-vote"`
 
54
}
 
55
 
 
56
// ApplicationStatus holds status info about an application.
 
57
type ApplicationStatus struct {
 
58
        Err             error                  `json:"err,omitempty"`
 
59
        Charm           string                 `json:"charm"`
 
60
        Series          string                 `json:"series"`
 
61
        Exposed         bool                   `json:"exposed"`
 
62
        Life            string                 `json:"life"`
 
63
        Relations       map[string][]string    `json:"relations"`
 
64
        CanUpgradeTo    string                 `json:"can-upgrade-to"`
 
65
        SubordinateTo   []string               `json:"subordinate-to"`
 
66
        Units           map[string]UnitStatus  `json:"units"`
 
67
        MeterStatuses   map[string]MeterStatus `json:"meter-statuses"`
 
68
        Status          DetailedStatus         `json:"status"`
 
69
        WorkloadVersion string                 `json:"workload-version"`
 
70
}
 
71
 
 
72
// MeterStatus represents the meter status of a unit.
 
73
type MeterStatus struct {
 
74
        Color   string `json:"color"`
 
75
        Message string `json:"message"`
 
76
}
 
77
 
 
78
// UnitStatus holds status info about a unit.
 
79
type UnitStatus struct {
 
80
        // AgentStatus holds the status for a unit's agent.
 
81
        AgentStatus DetailedStatus `json:"agent-status"`
 
82
 
 
83
        // WorkloadStatus holds the status for a unit's workload
 
84
        WorkloadStatus  DetailedStatus `json:"workload-status"`
 
85
        WorkloadVersion string         `json:"workload-version"`
 
86
 
 
87
        Machine       string                `json:"machine"`
 
88
        OpenedPorts   []string              `json:"opened-ports"`
 
89
        PublicAddress string                `json:"public-address"`
 
90
        Charm         string                `json:"charm"`
 
91
        Subordinates  map[string]UnitStatus `json:"subordinates"`
 
92
}
 
93
 
 
94
// RelationStatus holds status info about a relation.
 
95
type RelationStatus struct {
 
96
        Id        int              `json:"id"`
 
97
        Key       string           `json:"key"`
 
98
        Interface string           `json:"interface"`
 
99
        Scope     string           `json:"scope"`
 
100
        Endpoints []EndpointStatus `json:"endpoints"`
 
101
}
 
102
 
 
103
// EndpointStatus holds status info about a single endpoint
 
104
type EndpointStatus struct {
 
105
        ApplicationName string `json:"application"`
 
106
        Name            string `json:"name"`
 
107
        Role            string `json:"role"`
 
108
        Subordinate     bool   `json:"subordinate"`
 
109
}
 
110
 
 
111
// TODO(ericsnow) Eliminate the String method.
 
112
 
 
113
func (epStatus *EndpointStatus) String() string {
 
114
        return epStatus.ApplicationName + ":" + epStatus.Name
 
115
}
 
116
 
 
117
// DetailedStatus holds status info about a machine or unit agent.
 
118
type DetailedStatus struct {
 
119
        Status  string                 `json:"status"`
 
120
        Info    string                 `json:"info"`
 
121
        Data    map[string]interface{} `json:"data"`
 
122
        Since   *time.Time             `json:"since"`
 
123
        Kind    string                 `json:"kind"`
 
124
        Version string                 `json:"version"`
 
125
        Life    string                 `json:"life"`
 
126
        Err     error                  `json:"err,omitempty"`
 
127
}
 
128
 
 
129
// History holds many DetailedStatus,
 
130
type History struct {
 
131
        Statuses []DetailedStatus `json:"statuses"`
 
132
        Error    *Error           `json:"error,omitempty"`
 
133
}
 
134
 
 
135
// StatusHistoryFilter holds arguments that can be use to filter a status history backlog.
 
136
type StatusHistoryFilter struct {
 
137
        Size  int            `json:"size"`
 
138
        Date  *time.Time     `json:"date"`
 
139
        Delta *time.Duration `json:"delta"`
 
140
}
 
141
 
 
142
// StatusHistoryRequest holds the parameters to filter a status history query.
 
143
type StatusHistoryRequest struct {
 
144
        Kind   string              `json:"historyKind"`
 
145
        Size   int                 `json:"size"`
 
146
        Filter StatusHistoryFilter `json:"filter"`
 
147
        Tag    string              `json:"tag"`
 
148
}
 
149
 
 
150
// StatusHistoryRequests holds a slice of StatusHistoryArgs
 
151
type StatusHistoryRequests struct {
 
152
        Requests []StatusHistoryRequest `json:"requests"`
 
153
}
 
154
 
 
155
// StatusHistoryResult holds a slice of statuses.
 
156
type StatusHistoryResult struct {
 
157
        History History `json:"history"`
 
158
        Error   *Error  `json:"error,omitempty"`
 
159
}
 
160
 
 
161
// StatusHistoryResults holds a slice of StatusHistoryResult.
 
162
type StatusHistoryResults struct {
 
163
        Results []StatusHistoryResult `json:"results"`
 
164
}
 
165
 
 
166
// StatusHistoryPruneArgs holds arguments for status history
 
167
// prunning process.
 
168
type StatusHistoryPruneArgs struct {
 
169
        MaxHistoryTime time.Duration `json:"max-history-time"`
 
170
        MaxHistoryMB   int           `json:"max-history-mb"`
 
171
}
 
172
 
 
173
// StatusResult holds an entity status, extra information, or an
 
174
// error.
 
175
type StatusResult struct {
 
176
        Error  *Error                 `json:"error,omitempty"`
 
177
        Id     string                 `json:"id"`
 
178
        Life   Life                   `json:"life"`
 
179
        Status string                 `json:"status"`
 
180
        Info   string                 `json:"info"`
 
181
        Data   map[string]interface{} `json:"data"`
 
182
        Since  *time.Time             `json:"since"`
 
183
}
 
184
 
 
185
// StatusResults holds multiple status results.
 
186
type StatusResults struct {
 
187
        Results []StatusResult `json:"results"`
 
188
}
 
189
 
 
190
// ApplicationStatusResult holds results for an application Full Status
 
191
type ApplicationStatusResult struct {
 
192
        Application StatusResult            `json:"application"`
 
193
        Units       map[string]StatusResult `json:"units"`
 
194
        Error       *Error                  `json:"error,omitempty"`
 
195
}
 
196
 
 
197
// ApplicationStatusResults holds multiple StatusResult.
 
198
type ApplicationStatusResults struct {
 
199
        Results []ApplicationStatusResult `json:"results"`
 
200
}
 
201
 
 
202
// Life describes the lifecycle state of an entity ("alive", "dying" or "dead").
 
203
type Life multiwatcher.Life
 
204
 
 
205
const (
 
206
        Alive Life = "alive"
 
207
        Dying Life = "dying"
 
208
        Dead  Life = "dead"
 
209
)