1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENCE file for details.
6
import "github.com/juju/utils/set"
9
// Capability constants.
10
NetworksManagement = "networks-management"
11
StaticIPAddresses = "static-ipaddresses"
12
IPv6DeploymentUbuntu = "ipv6-deployment-ubuntu"
13
DevicesManagement = "devices-management"
14
StorageDeploymentUbuntu = "storage-deployment-ubuntu"
15
NetworkDeploymentUbuntu = "network-deployment-ubuntu"
18
// Controller represents an API connection to a MAAS Controller. Since the API
19
// is restful, there is no long held connection to the API server, but instead
20
// HTTP calls are made and JSON response structures parsed.
21
type Controller interface {
23
// Capabilities returns a set of capabilities as defined by the string
25
Capabilities() set.Strings
27
BootResources() ([]BootResource, error)
29
// Fabrics returns the list of Fabrics defined in the MAAS controller.
30
Fabrics() ([]Fabric, error)
32
// Spaces returns the list of Spaces defined in the MAAS controller.
33
Spaces() ([]Space, error)
35
// Zones lists all the zones known to the MAAS controller.
36
Zones() ([]Zone, error)
38
// Machines returns a list of machines that match the params.
39
Machines(MachinesArgs) ([]Machine, error)
41
// AllocateMachine will attempt to allocate a machine to the user.
42
// If successful, the allocated machine is returned.
43
AllocateMachine(AllocateMachineArgs) (Machine, ConstraintMatches, error)
45
// ReleaseMachines will stop the specified machines, and release them
46
// from the user making them available to be allocated again.
47
ReleaseMachines(ReleaseMachinesArgs) error
49
// Devices returns a list of devices that match the params.
50
Devices(DevicesArgs) ([]Device, error)
52
// CreateDevice creates and returns a new Device.
53
CreateDevice(CreateDeviceArgs) (Device, error)
55
// Files returns all the files that match the specified prefix.
56
Files(prefix string) ([]File, error)
58
// Return a single file by its filename.
59
GetFile(filename string) (File, error)
61
// AddFile adds or replaces the content of the specified filename.
62
// If or when the MAAS api is able to return metadata about a single
63
// file without sending the content of the file, we can return a File
65
AddFile(AddFileArgs) error
68
// File represents a file stored in the MAAS controller.
70
// Filename is the name of the file. No path, just the filename.
73
// AnonymousURL is a URL that can be used to retrieve the conents of the
74
// file without credentials.
77
// Delete removes the file from the MAAS controller.
80
// ReadAll returns the content of the file.
81
ReadAll() ([]byte, error)
84
// Fabric represents a set of interconnected VLANs that are capable of mutual
85
// communication. A fabric can be thought of as a logical grouping in which
86
// VLANs can be considered unique.
88
// For example, a distributed network may have a fabric in London containing
89
// VLAN 100, while a separate fabric in San Francisco may contain a VLAN 100,
90
// whose attached subnets are completely different and unrelated.
91
type Fabric interface {
99
// VLAN represents an instance of a Virtual LAN. VLANs are a common way to
100
// create logically separate networks using the same physical infrastructure.
102
// Managed switches can assign VLANs to each port in either a “tagged” or an
103
// “untagged” manner. A VLAN is said to be “untagged” on a particular port when
104
// it is the default VLAN for that port, and requires no special configuration
105
// in order to access.
107
// “Tagged” VLANs (traditionally used by network administrators in order to
108
// aggregate multiple networks over inter-switch “trunk” lines) can also be used
109
// with nodes in MAAS. That is, if a switch port is configured such that
110
// “tagged” VLAN frames can be sent and received by a MAAS node, that MAAS node
111
// can be configured to automatically bring up VLAN interfaces, so that the
112
// deployed node can make use of them.
114
// A “Default VLAN” is created for every Fabric, to which every new VLAN-aware
115
// object in the fabric will be associated to by default (unless otherwise
117
type VLAN interface {
122
// VID is the VLAN ID. eth0.10 -> VID = 10.
124
// MTU (maximum transmission unit) is the largest size packet or frame,
125
// specified in octets (eight-bit bytes), that can be sent.
130
SecondaryRack() string
133
// Zone represents a physical zone that a Machine is in. The meaning of a
134
// physical zone is up to you: it could identify e.g. a server rack, a network,
135
// or a data centre. Users can then allocate nodes from specific physical zones,
136
// to suit their redundancy or performance requirements.
137
type Zone interface {
142
// BootResource is the bomb... find something to say here.
143
type BootResource interface {
147
Architecture() string
148
SubArchitectures() set.Strings
149
KernelFlavor() string
152
// Device represents some form of device in MAAS.
153
type Device interface {
158
IPAddresses() []string
161
// Parent returns the SystemID of the Parent. Most often this will be a
165
// Owner is the username of the user that created the device.
168
// InterfaceSet returns all the interfaces for the Device.
169
InterfaceSet() []Interface
171
// CreateInterface will create a physical interface for this machine.
172
CreateInterface(CreateInterfaceArgs) (Interface, error)
174
// Delete will remove this Device.
178
// Machine represents a physical machine.
179
type Machine interface {
185
OperatingSystem() string
186
DistroSeries() string
187
Architecture() string
191
IPAddresses() []string
194
// Devices returns a list of devices that match the params and have
195
// this Machine as the parent.
196
Devices(DevicesArgs) ([]Device, error)
198
// Consider bundling the status values into a single struct.
199
// but need to check for consistent representation if exposed on other
203
StatusMessage() string
205
// BootInterface returns the interface that was used to boot the Machine.
206
BootInterface() Interface
207
// InterfaceSet returns all the interfaces for the Machine.
208
InterfaceSet() []Interface
209
// Interface returns the interface for the machine that matches the id
210
// specified. If there is no match, nil is returned.
211
Interface(id int) Interface
213
// PhysicalBlockDevices returns all the physical block devices on the machine.
214
PhysicalBlockDevices() []BlockDevice
215
// PhysicalBlockDevice returns the physical block device for the machine
216
// that matches the id specified. If there is no match, nil is returned.
217
PhysicalBlockDevice(id int) BlockDevice
219
// BlockDevices returns all the physical and virtual block devices on the machine.
220
BlockDevices() []BlockDevice
224
// Start the machine and install the operating system specified in the args.
225
Start(StartArgs) error
227
// CreateDevice creates a new Device with this Machine as the parent.
228
// The device will have one interface that is linked to the specified subnet.
229
CreateDevice(CreateMachineDeviceArgs) (Device, error)
232
// Space is a name for a collection of Subnets.
233
type Space interface {
239
// Subnet refers to an IP range on a VLAN.
240
type Subnet interface {
250
// DNSServers is a list of ip addresses of the DNS servers for the subnet.
251
// This list may be empty.
252
DNSServers() []string
255
// Interface represents a physical or virtual network interface on a Machine.
256
type Interface interface {
259
// The parents of an interface are the names of interfaces that must exist
260
// for this interface to exist. For example a parent of "eth0.100" would be
261
// "eth0". Parents may be empty.
263
// The children interfaces are the names of those that are dependent on this
264
// interface existing. Children may be empty.
276
// Params is a JSON field, and defaults to an empty string, but is almost
277
// always a JSON object in practice. Gleefully ignoring it until we need it.
279
// Update the name, mac address or VLAN.
280
Update(UpdateInterfaceArgs) error
282
// Delete this interface.
285
// LinkSubnet will attempt to make this interface available on the specified
287
LinkSubnet(LinkSubnetArgs) error
289
// UnlinkSubnet will remove the Link to the subnet, and release the IP
290
// address associated if there is one.
291
UnlinkSubnet(Subnet) error
294
// Link represents a network link between an Interface and a Subnet.
295
type Link interface {
299
// IPAddress returns the address if one has been assigned.
300
// If unavailble, the address will be empty.
304
// FileSystem represents a formatted filesystem mounted at a location.
305
type FileSystem interface {
306
// Type is the format type, e.g. "ext4".
314
// Partition represents a partition of a block device. It may be mounted
316
type Partition interface {
319
// FileSystem may be nil if not mounted.
320
FileSystem() FileSystem
322
// UsedFor is a human readable string.
324
// Size is the number of bytes in the partition.
328
// BlockDevice represents an entire block device on the machine.
329
type BlockDevice interface {
341
Partitions() []Partition
343
// There are some other attributes for block devices, but we can
344
// expose them on an as needed basis.