1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"github.com/juju/version"
10
"gopkg.in/juju/names.v2"
13
// HasAnnotations defines the common methods for setting and
14
// getting annotations for the various entities.
15
type HasAnnotations interface {
16
Annotations() map[string]string
17
SetAnnotations(map[string]string)
20
// HasConstraints defines the common methods for setting and
21
// getting constraints for the various entities.
22
type HasConstraints interface {
23
Constraints() Constraints
24
SetConstraints(ConstraintsArgs)
27
// HasStatus defines the common methods for setting and getting status
28
// entries for the various entities.
29
type HasStatus interface {
34
// HasStatusHistory defines the common methods for setting and
35
// getting historical status entries for the various entities.
36
type HasStatusHistory interface {
37
StatusHistory() []Status
38
SetStatusHistory([]StatusArgs)
41
// Model is a database agnostic representation of an existing model.
42
type Model interface {
48
CloudCredential() string
51
Config() map[string]interface{}
52
LatestToolsVersion() version.Number
54
// UpdateConfig overwrites existing config values with those specified.
55
UpdateConfig(map[string]interface{})
57
// Blocks returns a map of block type to the message associated with that
59
Blocks() map[string]string
65
AddMachine(MachineArgs) Machine
67
Applications() []Application
68
AddApplication(ApplicationArgs) Application
70
Relations() []Relation
71
AddRelation(RelationArgs) Relation
74
AddSpace(SpaceArgs) Space
76
LinkLayerDevices() []LinkLayerDevice
77
AddLinkLayerDevice(LinkLayerDeviceArgs) LinkLayerDevice
80
AddSubnet(SubnetArgs) Subnet
82
IPAddresses() []IPAddress
83
AddIPAddress(IPAddressArgs) IPAddress
85
SSHHostKeys() []SSHHostKey
86
AddSSHHostKey(SSHHostKeyArgs) SSHHostKey
88
Sequences() map[string]int
89
SetSequence(name string, value int)
92
AddVolume(VolumeArgs) Volume
94
Filesystems() []Filesystem
95
AddFilesystem(FilesystemArgs) Filesystem
100
// User represents a user of the model. Users are able to connect to, and
101
// depending on the read only flag, modify the model.
102
type User interface {
105
CreatedBy() names.UserTag
106
DateCreated() time.Time
107
LastConnection() time.Time
111
// Address represents an IP Address of some form.
112
type Address interface {
119
// AgentTools represent the version and related binary file
120
// that the machine and unit agents are using.
121
type AgentTools interface {
122
Version() version.Binary
128
// Machine represents an existing live machine or container running in the
130
type Machine interface {
137
Tag() names.MachineTag
139
PasswordHash() string
142
ContainerType() string
144
SupportedContainers() ([]string, bool)
146
Instance() CloudInstance
147
SetInstance(CloudInstanceArgs)
149
// Life() string -- only transmit alive things?
150
ProviderAddresses() []Address
151
MachineAddresses() []Address
152
SetAddresses(machine []AddressArgs, provider []AddressArgs)
154
PreferredPublicAddress() Address
155
PreferredPrivateAddress() Address
156
SetPreferredAddresses(public AddressArgs, private AddressArgs)
159
SetTools(AgentToolsArgs)
161
Containers() []Machine
162
AddContainer(MachineArgs) Machine
167
BlockDevices() []BlockDevice
168
AddBlockDevice(BlockDeviceArgs) BlockDevice
170
OpenedPorts() []OpenedPorts
171
AddOpenedPorts(OpenedPortsArgs) OpenedPorts
173
// THINKING: Validate() error to make sure the machine has
174
// enough stuff set, like tools, and addresses etc.
180
// machine filesystems
183
// OpenedPorts represents a collection of port ranges that are open on a
184
// particular subnet. OpenedPorts are always associated with a Machine.
185
type OpenedPorts interface {
187
OpenPorts() []PortRange
190
// PortRange represents one or more contiguous ports opened by a particular
192
type PortRange interface {
199
// CloudInstance holds information particular to a machine
200
// instance in a cloud.
201
type CloudInstance interface {
204
Architecture() string
210
AvailabilityZone() string
213
// Constraints holds information about particular deployment
214
// constraints for entities.
215
type Constraints interface {
216
Architecture() string
220
InstanceType() string
230
// Status represents an agent, application, or workload status.
231
type Status interface {
234
Data() map[string]interface{}
238
// Application represents a deployed charm in a model.
239
type Application interface {
245
Tag() names.ApplicationTag
251
CharmModifiedVersion() int
256
Settings() map[string]interface{}
257
SettingsRefCount() int
260
LeadershipSettings() map[string]interface{}
262
MetricsCredentials() []byte
265
AddUnit(UnitArgs) Unit
270
// Unit represents an instance of an application in a model.
271
type Unit interface {
277
Machine() names.MachineTag
279
PasswordHash() string
281
Principal() names.UnitTag
282
Subordinates() []names.UnitTag
284
MeterStatusCode() string
285
MeterStatusInfo() string
290
SetTools(AgentToolsArgs)
292
WorkloadStatus() Status
293
SetWorkloadStatus(StatusArgs)
295
WorkloadStatusHistory() []Status
296
SetWorkloadStatusHistory([]StatusArgs)
298
WorkloadVersion() string
300
WorkloadVersionHistory() []Status
301
SetWorkloadVersionHistory([]StatusArgs)
304
SetAgentStatus(StatusArgs)
306
AgentStatusHistory() []Status
307
SetAgentStatusHistory([]StatusArgs)
312
// Relation represents a relationship between two applications,
313
// or a peer relation between different instances of an application.
314
type Relation interface {
318
Endpoints() []Endpoint
319
AddEndpoint(EndpointArgs) Endpoint
322
// Endpoint represents one end of a relation. A named endpoint provided
323
// by the charm that is deployed for the application.
324
type Endpoint interface {
325
ApplicationName() string
327
// Role, Interface, Optional, Limit, and Scope should all be available
328
// through the Charm associated with the Application. There is no real need
329
// for this information to be denormalised like this. However, for now,
330
// since the import may well take place before the charms have been loaded
331
// into the model, we'll send this information over.
338
// UnitCount returns the number of units the endpoint has settings for.
341
Settings(unitName string) map[string]interface{}
342
SetUnitSettings(unitName string, settings map[string]interface{})
345
// Space represents a network space, which is a named collection of subnets.
346
type Space interface {
352
// LinkLayerDevice represents a link layer device.
353
type LinkLayerDevice interface {
365
// Subnet represents a network subnet.
366
type Subnet interface {
370
AvailabilityZone() string
372
AllocatableIPHigh() string
373
AllocatableIPLow() string
376
// IPAddress represents an IP address.
377
type IPAddress interface {
382
ConfigMethod() string
384
DNSServers() []string
385
DNSSearchDomains() []string
386
GatewayAddress() string
389
// SSHHostKey represents an ssh host key.
390
type SSHHostKey interface {
395
// Volume represents a volume (disk, logical volume, etc.) in the model.
396
type Volume interface {
400
Tag() names.VolumeTag
401
Storage() names.StorageTag
403
Binding() (names.Tag, error)
414
Attachments() []VolumeAttachment
415
AddAttachment(VolumeAttachmentArgs) VolumeAttachment
418
// VolumeAttachment represents a volume attached to a machine.
419
type VolumeAttachment interface {
420
Machine() names.MachineTag
428
// Filesystem represents a filesystem in the model.
429
type Filesystem interface {
433
Tag() names.FilesystemTag
434
Volume() names.VolumeTag
435
Storage() names.StorageTag
436
Binding() (names.Tag, error)
443
FilesystemID() string
445
Attachments() []FilesystemAttachment
446
AddAttachment(FilesystemAttachmentArgs) FilesystemAttachment
449
// FilesystemAttachment represents a filesystem attached to a machine.
450
type FilesystemAttachment interface {
451
Machine() names.MachineTag