/
internal.go
631 lines (531 loc) · 16 KB
/
internal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package params
import (
"time"
"github.com/juju/utils/exec"
"github.com/juju/juju/constraints"
"github.com/juju/juju/environs/network"
"github.com/juju/juju/instance"
"github.com/juju/juju/tools"
"github.com/juju/juju/version"
)
// MachineContainersParams holds the arguments for making a SetSupportedContainers
// API call.
type MachineContainersParams struct {
Params []MachineContainers
}
// MachineContainers holds the arguments for making an SetSupportedContainers call
// on a given machine.
type MachineContainers struct {
MachineTag string
ContainerTypes []instance.ContainerType
}
// WatchContainer identifies a single container type within a machine.
type WatchContainer struct {
MachineTag string
ContainerType string
}
// WatchContainers holds the arguments for making a WatchContainers
// API call.
type WatchContainers struct {
Params []WatchContainer
}
// CharmURL identifies a single charm URL.
type CharmURL struct {
URL string
}
// CharmURLs identifies multiple charm URLs.
type CharmURLs struct {
URLs []CharmURL
}
// StringsResult holds the result of an API call that returns a slice
// of strings or an error.
type StringsResult struct {
Error *Error
Result []string
}
// PortsResults holds the bulk operation result of an API call
// that returns a slice of instance.Port.
type PortsResults struct {
Results []PortsResult
}
// PortsResult holds the result of an API call that returns a slice
// of instance.Port or an error.
type PortsResult struct {
Error *Error
Ports []instance.Port
}
// StringsResults holds the bulk operation result of an API call
// that returns a slice of strings or an error.
type StringsResults struct {
Results []StringsResult
}
// StringResult holds a string or an error.
type StringResult struct {
Error *Error
Result string
}
// StringResults holds the bulk operation result of an API call
// that returns a string or an error.
type StringResults struct {
Results []StringResult
}
// CharmArchiveURLResult holds a charm archive (bundle) URL, a
// DisableSSLHostnameVerification flag or an error.
type CharmArchiveURLResult struct {
Error *Error
Result string
DisableSSLHostnameVerification bool
}
// CharmArchiveURLResults holds the bulk operation result of an API
// call that returns a charm archive (bundle) URL, a
// DisableSSLHostnameVerification flag or an error.
type CharmArchiveURLResults struct {
Results []CharmArchiveURLResult
}
// EnvironmentResult holds the result of an API call returning a name and UUID
// for an environment.
type EnvironmentResult struct {
Error *Error
Name string
UUID string
}
// ResolvedModeResult holds a resolved mode or an error.
type ResolvedModeResult struct {
Error *Error
Mode ResolvedMode
}
// ResolvedModeResults holds the bulk operation result of an API call
// that returns a resolved mode or an error.
type ResolvedModeResults struct {
Results []ResolvedModeResult
}
// StringBoolResult holds the result of an API call that returns a
// string and a boolean.
type StringBoolResult struct {
Error *Error
Result string
Ok bool
}
// StringBoolResults holds multiple results with a string and a bool
// each.
type StringBoolResults struct {
Results []StringBoolResult
}
// BoolResult holds the result of an API call that returns a
// a boolean or an error.
type BoolResult struct {
Error *Error
Result bool
}
// BoolResults holds multiple results with BoolResult each.
type BoolResults struct {
Results []BoolResult
}
// RelationSettings holds relation settings names and values.
type RelationSettings map[string]string
// RelationSettingsResult holds a relation settings map or an error.
type RelationSettingsResult struct {
Error *Error
Settings RelationSettings
}
// RelationSettingsResults holds the result of an API calls that
// returns settings for multiple relations.
type RelationSettingsResults struct {
Results []RelationSettingsResult
}
// ConfigSettings holds unit, service or cham configuration settings
// with string keys and arbitrary values.
type ConfigSettings map[string]interface{}
// ConfigSettingsResult holds a configuration map or an error.
type ConfigSettingsResult struct {
Error *Error
Settings ConfigSettings
}
// ConfigSettingsResults holds multiple configuration maps or errors.
type ConfigSettingsResults struct {
Results []ConfigSettingsResult
}
// EnvironConfig holds an environment configuration.
type EnvironConfig map[string]interface{}
// EnvironConfigResult holds environment configuration or an error.
type EnvironConfigResult struct {
Config EnvironConfig
}
// RelationUnit holds a relation and a unit tag.
type RelationUnit struct {
Relation string
Unit string
}
// RelationUnits holds the parameters for API calls expecting a pair
// of relation and unit tags.
type RelationUnits struct {
RelationUnits []RelationUnit
}
// RelationIds holds multiple relation ids.
type RelationIds struct {
RelationIds []int
}
// RelationUnitPair holds a relation tag, a local and remote unit tags.
type RelationUnitPair struct {
Relation string
LocalUnit string
RemoteUnit string
}
// RelationUnitPairs holds the parameters for API calls expecting
// multiple sets of a relation tag, a local and remote unit tags.
type RelationUnitPairs struct {
RelationUnitPairs []RelationUnitPair
}
// RelationUnitSettings holds a relation tag, a unit tag and local
// unit settings.
type RelationUnitSettings struct {
Relation string
Unit string
Settings RelationSettings
}
// RelationUnitsSettings holds the arguments for making a EnterScope
// or WriteSettings API calls.
type RelationUnitsSettings struct {
RelationUnits []RelationUnitSettings
}
// RelationResult returns information about a single relation,
// or an error.
type RelationResult struct {
Error *Error
Life Life
Id int
Key string
Endpoint Endpoint
}
// RelationResults holds the result of an API call that returns
// information about multiple relations.
type RelationResults struct {
Results []RelationResult
}
// EntityPort holds an entity's tag, a protocol and a port.
type EntityPort struct {
Tag string
Protocol string
Port int
}
// EntitiesPorts holds the parameters for making an OpenPort or
// ClosePort on some entities.
type EntitiesPorts struct {
Entities []EntityPort
}
// EntityCharmURL holds an entity's tag and a charm URL.
type EntityCharmURL struct {
Tag string
CharmURL string
}
// EntitiesCharmURL holds the parameters for making a SetCharmURL API
// call.
type EntitiesCharmURL struct {
Entities []EntityCharmURL
}
// BytesResult holds the result of an API call that returns a slice
// of bytes.
type BytesResult struct {
Result []byte
}
// LifeResult holds the life status of a single entity, or an error
// indicating why it is not available.
type LifeResult struct {
Life Life
Error *Error
}
// LifeResults holds the life or error status of multiple entities.
type LifeResults struct {
Results []LifeResult
}
// MachineSetProvisioned holds a machine tag, provider-specific
// instance id, a nonce, or an error.
//
// NOTE: This is deprecated since 1.19.0 and not used by the
// provisioner, it's just retained for backwards-compatibility and
// should be removed.
type MachineSetProvisioned struct {
Tag string
InstanceId instance.Id
Nonce string
Characteristics *instance.HardwareCharacteristics
}
// SetProvisioned holds the parameters for making a SetProvisioned
// call for a machine.
//
// NOTE: This is deprecated since 1.19.0 and not used by the
// provisioner, it's just retained for backwards-compatibility and
// should be removed.
type SetProvisioned struct {
Machines []MachineSetProvisioned
}
// Network describes a single network available on an instance.
type Network struct {
// Tag is the network's tag.
Tag string
// ProviderId is the provider-specific network id.
ProviderId network.Id
// CIDR of the network, in "123.45.67.89/12" format.
CIDR string
// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
// normal networks. It's defined by IEEE 802.1Q standard.
VLANTag int
}
// NetworkInterface describes a single network interface available on
// an instance.
type NetworkInterface struct {
// MACAddress is the network interface's hardware MAC address
// (e.g. "aa:bb:cc:dd:ee:ff").
MACAddress string
// InterfaceName is the OS-specific network device name (e.g.
// "eth1", even for for a VLAN eth1.42 virtual interface).
InterfaceName string
// NetworkTag is this interface's network tag.
NetworkTag string
// IsVirtual is true when the interface is a virtual device, as
// opposed to a physical device.
IsVirtual bool
}
// InstanceInfo holds a machine tag, provider-specific instance id, a
// nonce, a list of networks and interfaces to set up.
type InstanceInfo struct {
Tag string
InstanceId instance.Id
Nonce string
Characteristics *instance.HardwareCharacteristics
Networks []Network
Interfaces []NetworkInterface
}
// InstancesInfo holds the parameters for making a SetInstanceInfo
// call for multiple machines.
type InstancesInfo struct {
Machines []InstanceInfo
}
// RequestedNetworkResult holds requested networks or an error.
type RequestedNetworkResult struct {
Error *Error
Networks []string
}
// RequestedNetworksResults holds multiple requested networks results.
type RequestedNetworksResults struct {
Results []RequestedNetworkResult
}
// MachineNetworkInfoResult holds network info for a single machine.
type MachineNetworkInfoResult struct {
Error *Error
Info []network.Info
}
// MachineNetworkInfoResults holds network info for multiple machines.
type MachineNetworkInfoResults struct {
Results []MachineNetworkInfoResult
}
// EntityStatus holds an entity tag, status and extra info.
type EntityStatus struct {
Tag string
Status Status
Info string
Data StatusData
}
// SetStatus holds the parameters for making a SetStatus/UpdateStatus call.
type SetStatus struct {
Entities []EntityStatus
}
// StatusResult holds an entity status, extra information, or an
// error.
type StatusResult struct {
Error *Error
Id string
Life Life
Status Status
Info string
Data StatusData
}
// StatusResults holds multiple status results.
type StatusResults struct {
Results []StatusResult
}
// MachineAddresses holds an machine tag and addresses.
type MachineAddresses struct {
Tag string
Addresses []instance.Address
}
// SetMachinesAddresses holds the parameters for making a SetMachineAddresses call.
type SetMachinesAddresses struct {
MachineAddresses []MachineAddresses
}
// ConstraintsResult holds machine constraints or an error.
type ConstraintsResult struct {
Error *Error
Constraints constraints.Value
}
// ConstraintsResults holds multiple constraints results.
type ConstraintsResults struct {
Results []ConstraintsResult
}
// AgentGetEntitiesResults holds the results of a
// agent.API.GetEntities call.
type AgentGetEntitiesResults struct {
Entities []AgentGetEntitiesResult
}
// AgentGetEntitiesResult holds the results of a
// machineagent.API.GetEntities call for a single entity.
type AgentGetEntitiesResult struct {
Life Life
Jobs []MachineJob
ContainerType instance.ContainerType
Error *Error
}
// VersionResult holds the version and possibly error for a given
// DesiredVersion() API call.
type VersionResult struct {
Version *version.Number
Error *Error
}
// VersionResults is a list of versions for the requested entities.
type VersionResults struct {
Results []VersionResult
}
// ToolsResult holds the tools and possibly error for a given
// Tools() API call.
type ToolsResult struct {
Tools *tools.Tools
DisableSSLHostnameVerification bool
Error *Error
}
// ToolsResults is a list of tools for various requested agents.
type ToolsResults struct {
Results []ToolsResult
}
// FindToolsParams defines parameters for the FindTools method.
type FindToolsParams struct {
MajorVersion int
MinorVersion int
Arch string
Series string
}
// FindToolsResults holds a list of tools from FindTools and any error.
type FindToolsResults struct {
List tools.List
Error *Error
}
// Version holds a specific binary version.
type Version struct {
Version version.Binary
}
// EntityVersion specifies the tools version to be set for an entity
// with the given tag.
// version.Binary directly.
type EntityVersion struct {
Tag string
Tools *Version
}
// EntitiesVersion specifies what tools are being run for
// multiple entities.
type EntitiesVersion struct {
AgentTools []EntityVersion
}
// NotifyWatchResult holds a NotifyWatcher id and an error (if any).
type NotifyWatchResult struct {
NotifyWatcherId string
Error *Error
}
// NotifyWatchResults holds the results for any API call which ends up
// returning a list of NotifyWatchers
type NotifyWatchResults struct {
Results []NotifyWatchResult
}
// StringsWatchResult holds a StringsWatcher id, changes and an error
// (if any).
type StringsWatchResult struct {
StringsWatcherId string
Changes []string
Error *Error
}
// StringsWatchResults holds the results for any API call which ends up
// returning a list of StringsWatchers.
type StringsWatchResults struct {
Results []StringsWatchResult
}
// UnitSettings holds information about a service unit's settings
// within a relation.
type UnitSettings struct {
Version int64
}
// RelationUnitsChange holds notifications of units entering and leaving the
// scope of a RelationUnit, and changes to the settings of those units known
// to have entered.
//
// When remote units first enter scope and then when their settings
// change, the changes will be noted in the Changed field, which holds
// the unit settings for every such unit, indexed by the unit id.
//
// When remote units leave scope, their ids will be noted in the
// Departed field, and no further events will be sent for those units.
type RelationUnitsChange struct {
Changed map[string]UnitSettings
Departed []string
}
// RelationUnitsWatchResult holds a RelationUnitsWatcher id, changes
// and an error (if any).
type RelationUnitsWatchResult struct {
RelationUnitsWatcherId string
Changes RelationUnitsChange
Error *Error
}
// RelationUnitsWatchResults holds the results for any API call which ends up
// returning a list of RelationUnitsWatchers.
type RelationUnitsWatchResults struct {
Results []RelationUnitsWatchResult
}
// CharmsResponse is the server response to charm upload or GET requests.
type CharmsResponse struct {
Error string `json:",omitempty"`
CharmURL string `json:",omitempty"`
Files []string `json:",omitempty"`
}
// RunParams is used to provide the parameters to the Run method.
// Commands and Timeout are expected to have values, and one or more
// values should be in the Machines, Services, or Units slices.
type RunParams struct {
Commands string
Timeout time.Duration
Machines []string
Services []string
Units []string
}
// RunResult contains the result from an individual run call on a machine.
// UnitId is populated if the command was run inside the unit context.
type RunResult struct {
exec.ExecResponse
MachineId string
UnitId string
Error string
}
// RunResults is used to return the slice of results. API server side calls
// need to return single structure values.
type RunResults struct {
Results []RunResult
}
// AgentVersionResult is used to return the current version number of the
// agent running the API server.
type AgentVersionResult struct {
Version version.Number
}
// ProvisioningInfo holds machine provisioning info.
type ProvisioningInfo struct {
Constraints constraints.Value
Series string
Placement string
Networks []string
}
// ProvisioningInfoResult holds machine provisioning info or an error.
type ProvisioningInfoResult struct {
Error *Error
Result *ProvisioningInfo
}
// ProvisioningInfoResults holds multiple machine provisioning info results.
type ProvisioningInfoResults struct {
Results []ProvisioningInfoResult
}