gomaasapi

package module
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2022 License: LGPL-3.0 Imports: 30 Imported by: 0

README

.. -*- mode: rst -*-

******************************
MAAS API client library for Go
******************************

This library serves as a minimal client for communicating with the MAAS web
API in Go programs.

For more information see the `project homepage`_.

.. _project homepage: https://github.com/juju/gomaasapi/v2

Documentation

Index

Constants

View Source
const (
	// Number of retries performed when the server returns a 503
	// response with a 'Retry-after' header.  A request will be issued
	// at most NumberOfRetries + 1 times.
	NumberOfRetries = 4

	RetryAfterHeaderName = "Retry-After"
)
View Source
const (

	// The node has been created and has a system ID assigned to it.
	NodeStatusDeclared = "0"

	//Testing and other commissioning steps are taking place.
	NodeStatusCommissioning = "1"

	// Smoke or burn-in testing has a found a problem.
	NodeStatusFailedTests = "2"

	// The node can’t be contacted.
	NodeStatusMissing = "3"

	// The node is in the general pool ready to be deployed.
	NodeStatusReady = "4"

	// The node is ready for named deployment.
	NodeStatusReserved = "5"

	// The node is powering a service from a charm or is ready for use with a fresh Ubuntu install.
	NodeStatusDeployed = "6"

	// The node has been removed from service manually until an admin overrides the retirement.
	NodeStatusRetired = "7"

	// The node is broken: a step in the node lifecyle failed. More details
	// can be found in the node's event log.
	NodeStatusBroken = "8"

	// The node is being installed.
	NodeStatusDeploying = "9"

	// The node has been allocated to a user and is ready for deployment.
	NodeStatusAllocated = "10"

	// The deployment of the node failed.
	NodeStatusFailedDeployment = "11"

	// The node is powering down after a release request.
	NodeStatusReleasing = "12"

	// The releasing of the node failed.
	NodeStatusFailedReleasing = "13"

	// The node is erasing its disks.
	NodeStatusDiskErasing = "14"

	// The node failed to erase its disks.
	NodeStatusFailedDiskErasing = "15"
)
View Source
const (
	// Capability constants.
	NetworksManagement      = "networks-management"
	StaticIPAddresses       = "static-ipaddresses"
	IPv6DeploymentUbuntu    = "ipv6-deployment-ubuntu"
	DevicesManagement       = "devices-management"
	StorageDeploymentUbuntu = "storage-deployment-ubuntu"
	NetworkDeploymentUbuntu = "network-deployment-ubuntu"
)

Variables

View Source
var DefaultIgnoreTrailSlashUrl = []string{
	"license-key/{osystem}/{distro_series}",
	"scripts/{name}",
	"nodes/{system_id}/blockdevices/{device_id}/partition/{id}",
}
View Source
var IgnoreTrailUrlSlashRegexPreCompile map[string]*regexp.Regexp
View Source
var NotImplemented = errors.New("Not implemented")

Functions

func AddAPIVersionToURL

func AddAPIVersionToURL(BaseURL, apiVersion string) string

AddAPIVersionToURL will add the version/<version>/ suffix to the given URL, handling trailing slashes. It shouldn't be called with a URL that already includes a version.

func EnsureTrailingSlash

func EnsureTrailingSlash(URL string) string

EnsureTrailingSlash appends a slash at the end of the given string unless there already is one. This is used to create the kind of normalized URLs that Django expects. (to avoid Django's redirection when an URL does not ends with a slash.)

func InternalError

func InternalError(w http.ResponseWriter, r *http.Request, err error)

InternalError replies to the request with an HTTP 500 internal error.

func IsBadRequestError

func IsBadRequestError(err error) bool

IsBadRequestError returns true if err is a NoMatchError.

func IsCannotCompleteError

func IsCannotCompleteError(err error) bool

IsCannotCompleteError returns true if err is a NoMatchError.

func IsDeserializationError

func IsDeserializationError(err error) bool

IsDeserializationError returns true if err is a DeserializationError.

func IsNoMatchError

func IsNoMatchError(err error) bool

IsNoMatchError returns true if err is a NoMatchError.

func IsPermissionError

func IsPermissionError(err error) bool

IsPermissionError returns true if err is a NoMatchError.

func IsUnexpectedError

func IsUnexpectedError(err error) bool

IsUnexpectedError returns true if err is an UnexpectedError.

func IsUnsupportedVersionError

func IsUnsupportedVersionError(err error) bool

IsUnsupportedVersionError returns true if err is an UnsupportedVersionError.

func JoinURLs

func JoinURLs(baseURL, path string) string

JoinURLs joins a base URL and a subpath together. Regardless of whether baseURL ends in a trailing slash (or even multiple trailing slashes), or whether there are any leading slashes at the begining of path, the two will always be joined together by a single slash.

func NameOrIDToID

func NameOrIDToID(v string, nameToID map[string]uint, minID, maxID uint) (ID uint, err error)

NameOrIDToID takes a string that contains eiter an integer ID or the name of a thing. It returns the integer ID contained or mapped to or panics.

func NewBadRequestError

func NewBadRequestError(message string) error

NewBadRequestError constructs a new BadRequestError and sets the location.

func NewCannotCompleteError

func NewCannotCompleteError(message string) error

NewCannotCompleteError constructs a new CannotCompleteError and sets the location.

func NewDeserializationError

func NewDeserializationError(format string, args ...interface{}) error

NewDeserializationError constructs a new DeserializationError and sets the location.

func NewNoMatchError

func NewNoMatchError(message string) error

NewNoMatchError constructs a new NoMatchError and sets the location.

func NewPermissionError

func NewPermissionError(message string) error

NewPermissionError constructs a new PermissionError and sets the location.

func NewUnexpectedError

func NewUnexpectedError(err error) error

NewUnexpectedError constructs a new UnexpectedError and sets the location.

func NewUnsupportedVersionError

func NewUnsupportedVersionError(format string, args ...interface{}) error

NewUnsupportedVersionError constructs a new UnsupportedVersionError and sets the location.

func PrettyJsonWriter

func PrettyJsonWriter(thing interface{}, w http.ResponseWriter)

func ReloadRegex

func ReloadRegex(regexUrl []string) error

func SplitVersionedURL

func SplitVersionedURL(url string) (string, string, bool)

SplitVersionedURL splits a versioned API URL (like http://maas.server/MAAS/api/2.0/) into a base URL (http://maas.server/MAAS/) and API version (2.0). If the URL doesn't include a version component the bool return value will be false.

func WrapWithDeserializationError

func WrapWithDeserializationError(err error, format string, args ...interface{}) error

WrapWithDeserializationError constructs a new DeserializationError with the specified message, and sets the location and returns a new error with the full error stack set including the error passed in.

func WrapWithUnsupportedVersionError

func WrapWithUnsupportedVersionError(err error) error

WrapWithUnsupportedVersionError constructs a new UnsupportedVersionError wrapping the passed error.

Types

type AddFileArgs

type AddFileArgs struct {
	Filename string
	Content  []byte
	Reader   io.Reader
	Length   int64
}

AddFileArgs is a argument struct for passing information into AddFile. One of Content or (Reader, Length) must be specified.

func (*AddFileArgs) Validate

func (a *AddFileArgs) Validate() error

Validate checks to make sure the filename has no slashes, and that one of Content or (Reader, Length) is specified.

type AddressRange

type AddressRange struct {
	Start string `json:"start"`

	End string `json:"end"`

	Purpose      []string `json:"purpose,omitempty"`
	NumAddresses uint     `json:"num_addresses"`
	// contains filtered or unexported fields
}

AddressRange is used to generate reserved IP address range lists

type AddressRangeList

type AddressRangeList struct {
	// contains filtered or unexported fields
}

AddressRangeList is a list of AddressRange

func (*AddressRangeList) Append

func (ranges *AddressRangeList) Append(startIP, endIP IP)

Append appends a new AddressRange to an AddressRangeList

type AllocateMachineArgs

type AllocateMachineArgs struct {
	Hostname     string
	SystemId     string
	Architecture string
	MinCPUCount  int
	// MinMemory represented in MB.
	MinMemory int
	Tags      []string
	NotTags   []string
	Zone      string
	Pool      string
	NotInZone []string
	NotInPool []string
	// Storage represents the required disks on the Machine. If any are specified
	// the first value is used for the root disk.
	Storage []StorageSpec
	// Interfaces represents a number of required interfaces on the machine.
	// Each InterfaceSpec relates to an individual network interface.
	Interfaces []InterfaceSpec
	// NotSpace is a machine level constraint, and applies to the entire machine
	// rather than specific interfaces.
	NotSpace  []string
	AgentName string
	Comment   string
	DryRun    bool
}

AllocateMachineArgs is an argument struct for passing args into Machine.Allocate.

func (*AllocateMachineArgs) Validate

func (a *AllocateMachineArgs) Validate() error

Validate makes sure that any labels specified in Storage or Interfaces are unique, and that the required specifications are valid. It also makes sure that any pools specified exist.

type BadRequestError

type BadRequestError struct {
	errors.Err
}

BadRequestError is returned when the requested action cannot be performed due to bad or incorrect parameters passed to the server.

type BlockDevice

type BlockDevice interface {
	StorageDevice

	Name() string
	Model() string
	IDPath() string

	BlockSize() uint64
	UsedSize() uint64

	Partitions() []Partition
}

BlockDevice represents an entire block device on the machine.

type BootResource

type BootResource interface {
	ID() int
	Name() string
	Type() string
	Architecture() string
	SubArchitectures() set.Strings
	KernelFlavor() string
}

BootResource is the bomb... find something to say here.

type CannotCompleteError

type CannotCompleteError struct {
	errors.Err
}

CannotCompleteError is returned when the requested action is unable to complete for some server side reason.

type Client

type Client struct {
	APIURL     *url.URL
	Signer     OAuthSigner
	HTTPClient *http.Client
}

Client represents a way to communicating with a MAAS API instance. It is stateless, so it can have concurrent requests in progress.

func NewAnonymousClient

func NewAnonymousClient(BaseURL string, apiVersion string) (*Client, error)

NewAnonymousClient creates a client that issues anonymous requests. BaseURL should refer to the root of the MAAS server path, e.g. http://my.maas.server.example.com/MAAS/ apiVersion should contain the version of the MAAS API that you want to use.

func NewAuthenticatedClient

func NewAuthenticatedClient(versionedURL, apiKey string) (*Client, error)

NewAuthenticatedClient parses the given MAAS API key into the individual OAuth tokens and creates an Client that will use these tokens to sign the requests it issues. versionedURL should be the location of the versioned API root of the MAAS server, e.g.: http://my.maas.server.example.com/MAAS/api/2.0/

func (Client) Delete

func (client Client) Delete(uri *url.URL) error

Delete deletes an object on the API, using an HTTP "DELETE" request.

func (Client) Get

func (client Client) Get(uri *url.URL, operation string, parameters url.Values) ([]byte, error)

Get performs an HTTP "GET" to the API. This may be either an API method invocation (if you pass its name in "operation") or plain resource retrieval (if you leave "operation" blank).

func (Client) GetURL

func (client Client) GetURL(uri *url.URL) *url.URL

GetURL returns the URL to a given resource on the API, based on its URI. The resource URI may be absolute or relative; either way the result is a full absolute URL including the network part.

func (Client) Post

func (client Client) Post(uri *url.URL, operation string, parameters url.Values, files map[string][]byte) ([]byte, error)

Post performs an HTTP "POST" to the API. This may be either an API method invocation (if you pass its name in "operation") or plain resource retrieval (if you leave "operation" blank).

func (Client) Put

func (client Client) Put(uri *url.URL, parameters url.Values) ([]byte, error)

Put updates an object on the API, using an HTTP "PUT" request.

type ConstraintMatches

type ConstraintMatches struct {
	// Interface is a mapping of the constraint label specified to the Interfaces
	// that match that constraint.
	Interfaces map[string][]Interface

	// Storage is a mapping of the constraint label specified to the StorageDevice
	// that match that constraint.
	Storage map[string][]StorageDevice
}

ConstraintMatches provides a way for the caller of AllocateMachine to determine .how the allocated machine matched the storage and interfaces constraints specified. The labels that were used in the constraints are the keys in the maps.

type Controller

type Controller interface {
	// APIVersionInfo returns the version and subversion strings for the MAAS
	// controller.
	APIVersionInfo() (string, string, error)

	// Capabilities returns a set of capabilities as defined by the string
	// constants.
	Capabilities() set.Strings

	BootResources() ([]BootResource, error)

	// Fabrics returns the list of Fabrics defined in the MAAS controller.
	Fabrics() ([]Fabric, error)

	// Spaces returns the list of Spaces defined in the MAAS controller.
	Spaces() ([]Space, error)

	// StaticRoutes returns the list of StaticRoutes defined in the MAAS controller.
	StaticRoutes() ([]StaticRoute, error)

	// Zones lists all the zones known to the MAAS controller.
	Zones() ([]Zone, error)

	// Pools lists all the pools known to the MAAS controller.
	Pools() ([]Pool, error)

	// Machines returns a list of machines that match the params.
	Machines(MachinesArgs) ([]Machine, error)

	// AllocateMachine will attempt to allocate a machine to the user.
	// If successful, the allocated machine is returned.
	AllocateMachine(AllocateMachineArgs) (Machine, ConstraintMatches, error)

	// ReleaseMachines will stop the specified machines, and release them
	// from the user making them available to be allocated again.
	ReleaseMachines(ReleaseMachinesArgs) error

	// Devices returns a list of devices that match the params.
	Devices(DevicesArgs) ([]Device, error)

	// CreateDevice creates and returns a new Device.
	CreateDevice(CreateDeviceArgs) (Device, error)

	// Files returns all the files that match the specified prefix.
	Files(prefix string) ([]File, error)

	// Return a single file by its filename.
	GetFile(filename string) (File, error)

	// AddFile adds or replaces the content of the specified filename.
	// If or when the MAAS api is able to return metadata about a single
	// file without sending the content of the file, we can return a File
	// instance here too.
	AddFile(AddFileArgs) error

	// Returns the DNS Domain Managed By MAAS
	Domains() ([]Domain, error)

	// Returns the list of MAAS tags
	Tags() ([]Tag, error)
}

Controller represents an API connection to a MAAS Controller. Since the API is restful, there is no long held connection to the API server, but instead HTTP calls are made and JSON response structures parsed.

func NewController

func NewController(args ControllerArgs) (Controller, error)

NewController creates an authenticated client to the MAAS API, and checks the capabilities of the server. If the BaseURL specified includes the API version, that version of the API will be used, otherwise the controller will use the highest supported version available.

If the APIKey is not valid, a NotValid error is returned. If the credentials are incorrect, a PermissionError is returned.

type ControllerArgs

type ControllerArgs struct {
	BaseURL    string
	APIKey     string
	HTTPClient *http.Client
}

ControllerArgs is an argument struct for passing the required parameters to the NewController method.

type CreateDeviceArgs

type CreateDeviceArgs struct {
	Hostname     string
	MACAddresses []string
	Domain       string
	Parent       string
}

CreateDeviceArgs is a argument struct for passing information into CreateDevice.

type CreateInterfaceArgs

type CreateInterfaceArgs struct {
	// Name of the interface (required).
	Name string
	// MACAddress is the MAC address of the interface (required).
	MACAddress string
	// VLAN is the untagged VLAN the interface is connected to (required).
	VLAN VLAN
	// Tags to attach to the interface (optional).
	Tags []string
	// MTU - Maximum transmission unit. (optional)
	MTU int
	// AcceptRA - Accept router advertisements. (IPv6 only)
	AcceptRA bool
	// Autoconf - Perform stateless autoconfiguration. (IPv6 only)
	Autoconf bool
}

CreateInterfaceArgs is an argument struct for passing parameters to the Machine.CreateInterface method.

func (*CreateInterfaceArgs) Validate

func (a *CreateInterfaceArgs) Validate() error

Validate checks the required fields are set for the arg structure.

type CreateMachineDeviceArgs

type CreateMachineDeviceArgs struct {
	Hostname      string
	Domain        string
	InterfaceName string
	MACAddress    string
	Subnet        Subnet
	VLAN          VLAN
}

CreateMachineDeviceArgs is an argument structure for Machine.CreateDevice. Only InterfaceName and MACAddress fields are required, the others are only used if set. If Subnet and VLAN are both set, Subnet.VLAN() must match the given VLAN. On failure, returns an error satisfying errors.IsNotValid().

func (*CreateMachineDeviceArgs) Validate

func (a *CreateMachineDeviceArgs) Validate() error

Validate ensures that all required values are non-emtpy.

type CreateSpace

type CreateSpace struct {
	Name string `json:"name"`
}

CreateSpace is used to create new spaces on the server.

type CreateStaticRoute

type CreateStaticRoute struct {
	SourceCIDR      string `json:"source"`
	DestinationCIDR string `json:"destination"`
	GatewayIP       string `json:"gateway_ip"`
	Metric          uint   `json:"metric"`
}

CreateStaticRoute is used to create new Static Routes on the server.

type CreateSubnet

type CreateSubnet struct {
	DNSServers []string `json:"dns_servers"`
	Name       string   `json:"name"`
	Space      string   `json:"space"`
	GatewayIP  string   `json:"gateway_ip"`
	CIDR       string   `json:"cidr"`

	// VLAN this subnet belongs to. Currently ignored.
	// TODO: Defaults to the default VLAN
	// for the provided fabric or defaults to the default VLAN
	// in the default fabric.
	VLAN *uint `json:"vlan"`

	// Fabric for the subnet. Currently ignored.
	// TODO: Defaults to the fabric the provided
	// VLAN belongs to or defaults to the default fabric.
	Fabric *uint `json:"fabric"`

	// VID of the VLAN this subnet belongs to. Currently ignored.
	// TODO: Only used when vlan
	// is not provided. Picks the VLAN with this VID in the provided
	// fabric or the default fabric if one is not given.
	VID *uint `json:"vid"`

	// This is used for updates (PUT) and is ignored by create (POST)
	ID uint `json:"id"`
}

CreateSubnet is used to receive new subnets via the MAAS API

type DeserializationError

type DeserializationError struct {
	errors.Err
}

DeserializationError types are returned when the returned JSON data from the controller doesn't match the code's expectations.

type Device

type Device interface {
	// TODO: add domain
	SystemID() string
	Hostname() string
	FQDN() string
	IPAddresses() []string
	Zone() Zone
	Pool() Pool

	// Parent returns the SystemID of the Parent. Most often this will be a
	// Machine.
	Parent() string

	// Owner is the username of the user that created the device.
	Owner() string

	// InterfaceSet returns all the interfaces for the Device.
	InterfaceSet() []Interface

	// CreateInterface will create a physical interface for this machine.
	CreateInterface(CreateInterfaceArgs) (Interface, error)

	// Delete will remove this Device.
	Delete() error
}

Device represents some form of device in MAAS.

type DevicesArgs

type DevicesArgs struct {
	Hostname     []string
	MACAddresses []string
	SystemIDs    []string
	Domain       string
	Zone         string
	Pool         string
	AgentName    string
}

DevicesArgs is a argument struct for selecting Devices. Only devices that match the specified criteria are returned.

type Domain

type Domain interface {
	// The name of the Domain
	Name() string
}

type Fabric

type Fabric interface {
	ID() int
	Name() string
	ClassType() string

	VLANs() []VLAN
}

Fabric represents a set of interconnected VLANs that are capable of mutual communication. A fabric can be thought of as a logical grouping in which VLANs can be considered unique.

For example, a distributed network may have a fabric in London containing VLAN 100, while a separate fabric in San Francisco may contain a VLAN 100, whose attached subnets are completely different and unrelated.

type File

type File interface {
	// Filename is the name of the file. No path, just the filename.
	Filename() string

	// AnonymousURL is a URL that can be used to retrieve the conents of the
	// file without credentials.
	AnonymousURL() string

	// Delete removes the file from the MAAS controller.
	Delete() error

	// ReadAll returns the content of the file.
	ReadAll() ([]byte, error)
}

File represents a file stored in the MAAS controller.

type FileSystem

type FileSystem interface {
	// Type is the format type, e.g. "ext4".
	Type() string

	MountPoint() string
	Label() string
	UUID() string
}

FileSystem represents a formatted filesystem mounted at a location.

type IP

type IP struct {
	Purpose []string
	// contains filtered or unexported fields
}

IP is an enhanced net.IP

func IPFromInt64

func IPFromInt64(v uint64) IP

IPFromInt64 creates a new IP from a uint64 IP address representation

func IPFromNetIP

func IPFromNetIP(netIP net.IP) IP

IPFromNetIP creates a IP from a net.IP.

func IPFromString

func IPFromString(v string) IP

IPFromString creates a new IP from a string IP address representation

func (*IP) SetUInt64

func (ip *IP) SetUInt64(v uint64)

SetUInt64 sets the IP value to v

func (IP) String

func (ip IP) String() string

func (IP) To16

func (ip IP) To16() net.IP

To16 converts the IP address ip to a 16-byte representation. If ip is not an IP address (it is the wrong length), To16 returns nil.

func (IP) To4

func (ip IP) To4() net.IP

To4 converts the IPv4 address ip to a 4-byte representation. If ip is not an IPv4 address, To4 returns nil.

func (IP) UInt64

func (ip IP) UInt64() uint64

UInt64 returns a uint64 holding the IP address

type Interface

type Interface interface {
	ID() int
	Name() string
	// The parents of an interface are the names of interfaces that must exist
	// for this interface  to exist. For example a parent of "eth0.100" would be
	// "eth0". Parents may be empty.
	Parents() []string
	// The children interfaces are the names of those that are dependent on this
	// interface existing. Children may be empty.
	Children() []string
	Type() string
	Enabled() bool
	Tags() []string

	VLAN() VLAN
	Links() []Link

	MACAddress() string
	EffectiveMTU() int

	// Update the name, mac address or VLAN.
	Update(UpdateInterfaceArgs) error

	// Delete this interface.
	Delete() error

	// LinkSubnet will attempt to make this interface available on the specified
	// Subnet.
	LinkSubnet(LinkSubnetArgs) error

	// UnlinkSubnet will remove the Link to the subnet, and release the IP
	// address associated if there is one.
	UnlinkSubnet(Subnet) error
}

Interface represents a physical or virtual network interface on a Machine.

type InterfaceLinkMode

type InterfaceLinkMode string

InterfaceLinkMode is the type of the various link mode constants used for LinkSubnetArgs.

const (
	// LinkModeDHCP - Bring the interface up with DHCP on the given subnet. Only
	// one subnet can be set to DHCP. If the subnet is managed this interface
	// will pull from the dynamic IP range.
	LinkModeDHCP InterfaceLinkMode = "DHCP"

	// LinkModeStatic - Bring the interface up with a STATIC IP address on the
	// given subnet. Any number of STATIC links can exist on an interface.
	LinkModeStatic InterfaceLinkMode = "STATIC"

	// LinkModeLinkUp - Bring the interface up only on the given subnet. No IP
	// address will be assigned to this interface. The interface cannot have any
	// current DHCP or STATIC links.
	LinkModeLinkUp InterfaceLinkMode = "LINK_UP"
)

type InterfaceSpec

type InterfaceSpec struct {
	// Label is required and an arbitrary string. Labels need to be unique
	// across the InterfaceSpec elements specified in the AllocateMachineArgs.
	// The label is returned in the ConstraintMatches response from
	// AllocateMachine.
	Label string
	Space string
}

InterfaceSpec represents one element of network related constraints.

func (*InterfaceSpec) String

func (a *InterfaceSpec) String() string

String returns the interface spec as MaaS requires it.

func (*InterfaceSpec) Validate

func (a *InterfaceSpec) Validate() error

Validate ensures that a Label is specified and that there is at least one Space or NotSpace value set.

type JSONObject

type JSONObject struct {
	// contains filtered or unexported fields
}

JSONObject is a wrapper around a JSON structure which provides methods to extract data from that structure. A JSONObject provides a simple structure consisting of the data types defined in JSON: string, number, object, list, and bool. To get the value you want out of a JSONObject, you must know (or figure out) which kind of value you have, and then call the appropriate Get*() method to get at it. Reading an item as the wrong type will return an error. For instance, if your JSONObject consists of a number, call GetFloat64() to get the value as a float64. If it's a list, call GetArray() to get a slice of JSONObjects. To read any given item from the slice, you'll need to "Get" that as the right type as well. There is one exception: a MAASObject is really a special kind of map, so you can read it as either. Reading a null item is also an error. So before you try obj.Get*(), first check obj.IsNil().

func JSONObjectFromStruct

func JSONObjectFromStruct(client Client, input interface{}) (JSONObject, error)

JSONObjectFromStruct takes a struct and converts it to a JSONObject

func Parse

func Parse(client Client, input []byte) (JSONObject, error)

Parse a JSON blob into a JSONObject.

func (JSONObject) GetArray

func (obj JSONObject) GetArray() (value []JSONObject, err error)

GetArray retrieves the object's value as an array. If the value wasn't a JSON list, that's an error.

func (JSONObject) GetBool

func (obj JSONObject) GetBool() (value bool, err error)

GetBool retrieves the object's value as a bool. If the value wasn't a JSON bool, that's an error.

func (JSONObject) GetBytes

func (obj JSONObject) GetBytes() ([]byte, error)

GetBytes retrieves the object's value as raw bytes. A JSONObject that was parsed from the original input (as opposed to one that's embedded in another JSONObject) can contain both the raw bytes and the parsed JSON value, but either can be the case without the other. If this object wasn't parsed directly from the original input, that's an error. If the object was parsed from an original input that just said "null", then IsNil will return true but the raw bytes are still available from GetBytes.

func (JSONObject) GetFloat64

func (obj JSONObject) GetFloat64() (value float64, err error)

GetFloat64 retrieves the object's value as a float64. If the value wasn't a JSON number, that's an error.

func (JSONObject) GetMAASObject

func (obj JSONObject) GetMAASObject() (MAASObject, error)

JSONObject getter for a MAAS object. From a decoding perspective, a MAASObject is just like a map except it contains a key "resource_uri", and it keeps track of the Client you got it from so that you can invoke API methods directly on their MAAS objects.

func (JSONObject) GetMap

func (obj JSONObject) GetMap() (value map[string]JSONObject, err error)

GetMap retrieves the object's value as a map. If the value wasn't a JSON object, that's an error.

func (JSONObject) GetString

func (obj JSONObject) GetString() (value string, err error)

GetString retrieves the object's value as a string. If the value wasn't a JSON string, that's an error.

func (JSONObject) IsNil

func (obj JSONObject) IsNil() bool

IsNil tells you whether a JSONObject is a JSON "null." There is one irregularity. If the original JSON blob was actually raw data, not JSON, then its IsNil will return false because the object contains the binary data as a non-nil value. But, if the original JSON blob consisted of a null, then IsNil returns true even though you can still retrieve binary data from it.

func (JSONObject) MarshalJSON

func (obj JSONObject) MarshalJSON() ([]byte, error)

MarshalJSON tells the standard json package how to serialize a JSONObject back to JSON.

type Link interface {
	ID() int
	Mode() string
	Subnet() Subnet
	// IPAddress returns the address if one has been assigned.
	// If unavailble, the address will be empty.
	IPAddress() string
}

Link represents a network link between an Interface and a Subnet.

type LinkSubnetArgs

type LinkSubnetArgs struct {
	// Mode is used to describe how the address is provided for the Link.
	// Required field.
	Mode InterfaceLinkMode
	// Subnet is the subnet to link to. Required field.
	Subnet Subnet
	// IPAddress is only valid when the Mode is set to LinkModeStatic. If
	// not specified with a Mode of LinkModeStatic, an IP address from the
	// subnet will be auto selected.
	IPAddress string
	// DefaultGateway will set the gateway IP address for the Subnet as the
	// default gateway for the machine or device the interface belongs to.
	// Option can only be used with mode LinkModeStatic.
	DefaultGateway bool
}

LinkSubnetArgs is an argument struct for passing parameters to the Interface.LinkSubnet method.

func (*LinkSubnetArgs) Validate

func (a *LinkSubnetArgs) Validate() error

Validate ensures that the Mode and Subnet are set, and that the other options are consistent with the Mode.

type MAASObject

type MAASObject struct {
	// contains filtered or unexported fields
}

MAASObject represents a MAAS object as returned by the MAAS API, such as a Node or a Tag. You can extract a MAASObject out of a JSONObject using JSONObject.GetMAASObject. A MAAS API call will usually return either a MAASObject or a list of MAASObjects. The list itself would be wrapped in a JSONObject, so if an API call returns a list of objects "l," you first obtain the array using l.GetArray(). Then, for each item "i" in the array, obtain the matching MAASObject using i.GetMAASObject().

func NewMAAS

func NewMAAS(client Client) *MAASObject

NewMAAS returns an interface to the MAAS API as a *MAASObject.

func (MAASObject) CallGet

func (obj MAASObject) CallGet(operation string, params url.Values) (JSONObject, error)

CallGet invokes an idempotent API method on this object.

func (MAASObject) CallPost

func (obj MAASObject) CallPost(operation string, params url.Values) (JSONObject, error)

CallPost invokes a non-idempotent API method on this object.

func (MAASObject) CallPostFiles

func (obj MAASObject) CallPostFiles(operation string, params url.Values, files map[string][]byte) (JSONObject, error)

CallPostFiles invokes a non-idempotent API method on this object. It is similar to CallPost but has an extra parameter, 'files', which should contain the files that will be uploaded to the API.

func (MAASObject) Delete

func (obj MAASObject) Delete() error

Delete removes this object on the API.

func (MAASObject) Get

func (obj MAASObject) Get() (MAASObject, error)

Get retrieves a fresh copy of this MAAS object from the API.

func (MAASObject) GetField

func (obj MAASObject) GetField(name string) (string, error)

GetField extracts a string field from this MAAS object.

func (MAASObject) GetMap

func (obj MAASObject) GetMap() map[string]JSONObject

GetMap returns all of the object's attributes in the form of a map.

func (MAASObject) GetSubObject

func (obj MAASObject) GetSubObject(name string) MAASObject

GetSubObject returns a new MAASObject representing the API resource found at a given sub-path of the current object's resource URI.

func (MAASObject) MarshalJSON

func (obj MAASObject) MarshalJSON() ([]byte, error)

MarshalJSON tells the standard json package how to serialize a MAASObject.

func (MAASObject) Post

func (obj MAASObject) Post(params url.Values) (JSONObject, error)

Post overwrites this object's existing value on the API with those given in "params." It returns the object's new value as received from the API.

func (MAASObject) URI

func (obj MAASObject) URI() *url.URL

URI is the resource URI for this MAAS object. It is an absolute path, but without a network part.

func (MAASObject) URL

func (obj MAASObject) URL() *url.URL

URL returns a full absolute URL (including network part) for this MAAS object on the API.

func (MAASObject) Update

func (obj MAASObject) Update(params url.Values) (MAASObject, error)

Update modifies this object on the API, based on the values given in "params." It returns the object's new value as received from the API.

type Machine

type Machine interface {
	OwnerDataHolder

	SystemID() string
	Hostname() string
	FQDN() string
	Tags() []string

	OperatingSystem() string
	DistroSeries() string
	Architecture() string
	Memory() int
	CPUCount() int
	HardwareInfo() map[string]string

	IPAddresses() []string
	PowerState() string

	// Devices returns a list of devices that match the params and have
	// this Machine as the parent.
	Devices(DevicesArgs) ([]Device, error)

	StatusName() string
	StatusMessage() string

	// BootInterface returns the interface that was used to boot the Machine.
	BootInterface() Interface
	// InterfaceSet returns all the interfaces for the Machine.
	InterfaceSet() []Interface
	// Interface returns the interface for the machine that matches the id
	// specified. If there is no match, nil is returned.
	Interface(id int) Interface

	// PhysicalBlockDevices returns all the physical block devices on the machine.
	PhysicalBlockDevices() []BlockDevice
	// PhysicalBlockDevice returns the physical block device for the machine
	// that matches the id specified. If there is no match, nil is returned.
	PhysicalBlockDevice(id int) BlockDevice

	// BlockDevices returns all the physical and virtual block devices on the machine.
	BlockDevices() []BlockDevice
	// BlockDevice returns the block device for the machine that matches the
	// id specified. If there is no match, nil is returned.
	BlockDevice(id int) BlockDevice

	// Partition returns the partition for the machine that matches the
	// id specified. If there is no match, nil is returned.
	Partition(id int) Partition

	Zone() Zone
	Pool() Pool

	// Start the machine and install the operating system specified in the args.
	Start(StartArgs) error

	// CreateDevice creates a new Device with this Machine as the parent.
	// The device will have one interface that is linked to the specified subnet.
	CreateDevice(CreateMachineDeviceArgs) (Device, error)
}

Machine represents a physical machine.

type MachinesArgs

type MachinesArgs struct {
	Hostnames    []string
	MACAddresses []string
	SystemIDs    []string
	Domain       string
	Zone         string
	Pool         string
	AgentName    string
	Tags         []string
	OwnerData    map[string]string
}

MachinesArgs is a argument struct for selecting Machines. Only machines that match the specified criteria are returned.

type NetworkLink struct {
	ID     uint        `json:"id"`
	Mode   string      `json:"mode"`
	Subnet *TestSubnet `json:"subnet"`
}

NetworkLink represents a MAAS network link

type NoMatchError

type NoMatchError struct {
	errors.Err
}

NoMatchError is returned when the requested action cannot be performed due to being unable to service due to no entities available that match the request.

type Node

type Node struct {
	SystemID   string                 `json:"system_id"`
	Interfaces []NodeNetworkInterface `json:"interface_set"`
}

Node represents a node

type NodeNetworkInterface

type NodeNetworkInterface struct {
	Name  string        `json:"name"`
	Links []NetworkLink `json:"links"`
}

NodeNetworkInterface represents a network interface attached to a node

type OAuthSigner

type OAuthSigner interface {
	OAuthSign(request *http.Request) error
}

func NewPlainTestOAuthSigner

func NewPlainTestOAuthSigner(token *OAuthToken, realm string) (OAuthSigner, error)

type OAuthToken

type OAuthToken struct {
	ConsumerKey    string
	ConsumerSecret string
	TokenKey       string
	TokenSecret    string
}

type OwnerDataHolder

type OwnerDataHolder interface {
	// OwnerData returns a copy of the key/value data stored for this
	// object.
	OwnerData() map[string]string

	// SetOwnerData updates the key/value data stored for this object
	// with the values passed in. Existing keys that aren't specified
	// in the map passed in will be left in place; to clear a key set
	// its value to "". All owner data is cleared when the object is
	// released.
	SetOwnerData(map[string]string) error
}

OwnerDataHolder represents any MAAS object that can store key/value data.

type Partition

type Partition interface {
	StorageDevice
}

Partition represents a partition of a block device. It may be mounted as a filesystem.

type PermissionError

type PermissionError struct {
	errors.Err
}

PermissionError is returned when the user does not have permission to do the requested action.

type Pool

type Pool interface {
	// The name of the resource pool
	Name() string
	Description() string
}

Pool is just a logical separation of resources.

type PostedVLAN

type PostedVLAN struct {
	Name string `json:"name"`
	VID  uint   `json:"vid"`
}

PostedVLAN is the MAAS API posted VLAN representation

type ReleaseMachinesArgs

type ReleaseMachinesArgs struct {
	SystemIDs []string
	Comment   string
}

ReleaseMachinesArgs is an argument struct for passing the machine system IDs and an optional comment into the ReleaseMachines method.

type ServerError

type ServerError struct {
	StatusCode  int
	Header      http.Header
	BodyMessage string
	// contains filtered or unexported fields
}

ServerError is an http error (or at least, a non-2xx result) received from the server. It contains the numerical HTTP status code as well as an error string and the response's headers.

func GetServerError

func GetServerError(err error) (ServerError, bool)

GetServerError returns the ServerError from the cause of the error if it is a ServerError, and also returns the bool to indicate if it was a ServerError or not.

type SimpleTestServer

type SimpleTestServer struct {
	*httptest.Server
	// contains filtered or unexported fields
}

func NewSimpleServer

func NewSimpleServer() *SimpleTestServer

func (*SimpleTestServer) AddDeleteResponse

func (s *SimpleTestServer) AddDeleteResponse(path string, status int, body string)

func (*SimpleTestServer) AddGetResponse

func (s *SimpleTestServer) AddGetResponse(path string, status int, body string)

func (*SimpleTestServer) AddPostResponse

func (s *SimpleTestServer) AddPostResponse(path string, status int, body string)

func (*SimpleTestServer) AddPutResponse

func (s *SimpleTestServer) AddPutResponse(path string, status int, body string)

func (*SimpleTestServer) LastNRequests

func (s *SimpleTestServer) LastNRequests(n int) []*http.Request

func (*SimpleTestServer) LastRequest

func (s *SimpleTestServer) LastRequest() *http.Request

func (*SimpleTestServer) RequestCount

func (s *SimpleTestServer) RequestCount() int

func (*SimpleTestServer) ResetRequests

func (s *SimpleTestServer) ResetRequests()

type Space

type Space interface {
	ID() int
	Name() string
	Subnets() []Subnet
}

Space is a name for a collection of Subnets.

type StartArgs

type StartArgs struct {
	// UserData needs to be Base64 encoded user data for cloud-init.
	UserData     string
	DistroSeries string
	Kernel       string
	Comment      string
}

StartArgs is an argument struct for passing parameters to the Machine.Start method.

type StaticRoute

type StaticRoute interface {
	// Source is the subnet that should have the route configured. (Machines
	// inside Source should use GatewayIP to reach Destination addresses.)
	Source() Subnet
	// Destination is the subnet that a machine wants to send packets to. We
	// want to configure a route to that subnet via GatewayIP.
	Destination() Subnet
	// GatewayIP is the IPAddress to direct traffic to.
	GatewayIP() string
	// Metric is the routing metric that determines whether this route will
	// take precedence over similar routes (there may be a route for 10/8, but
	// also a more concrete route for 10.0/16 that should take precedence if it
	// applies.) Metric should be a non-negative integer.
	Metric() int
}

StaticRoute defines an explicit route that users have requested to be added for a given subnet.

type StorageDevice

type StorageDevice interface {
	// Type is the type of item.
	Type() string

	// ID is the unique ID of the item of that type.
	ID() int

	Path() string
	UsedFor() string
	Size() uint64
	UUID() string
	Tags() []string

	// FileSystem may be nil if not mounted.
	FileSystem() FileSystem
}

StorageDevice represents any piece of storage on a machine. Partition and BlockDevice are storage devices.

type StorageSpec

type StorageSpec struct {
	// Label is optional and an arbitrary string. Labels need to be unique
	// across the StorageSpec elements specified in the AllocateMachineArgs.
	Label string
	// Size is required and refers to the required minimum size in GB.
	Size int
	// Zero or more tags associated to the disks.
	Tags []string
}

StorageSpec represents one element of storage constraints necessary to be satisfied to allocate a machine.

func (*StorageSpec) String

func (s *StorageSpec) String() string

String returns the string representation of the storage spec.

func (*StorageSpec) Validate

func (s *StorageSpec) Validate() error

Validate ensures that there is a positive size and that there are no Empty tag values.

type Subnet

type Subnet interface {
	ID() int
	Name() string
	Space() string
	VLAN() VLAN

	Gateway() string
	CIDR() string

	// DNSServers is a list of ip addresses of the DNS servers for the subnet.
	// This list may be empty.
	DNSServers() []string
}

Subnet refers to an IP range on a VLAN.

type SubnetStats

type SubnetStats struct {
	NumAvailable     uint           `json:"num_available"`
	LargestAvailable uint           `json:"largest_available"`
	NumUnavailable   uint           `json:"num_unavailable"`
	TotalAddresses   uint           `json:"total_addresses"`
	Usage            float32        `json:"usage"`
	UsageString      string         `json:"usage_string"`
	Ranges           []AddressRange `json:"ranges"`
}

SubnetStats holds statistics about a subnet

type Tag

type Tag interface {
	Name() string
	Comment() string
	Definition() string
	KernelOpts() string
}

Tag represents a MAAS tag.

type TestDevice

type TestDevice struct {
	IPAddresses  []string
	SystemId     string
	MACAddresses []string
	Parent       string
	Hostname     string

	// Not part of the device definition but used by the template.
	APIVersion string
}

type TestMAASObject

type TestMAASObject struct {
	MAASObject
	TestServer *TestServer
}

TestMAASObject is a fake MAAS server MAASObject.

func NewTestMAAS

func NewTestMAAS(version string) *TestMAASObject

NewTestMAAS returns a TestMAASObject that implements the MAASObject interface and thus can be used as a test object instead of the one returned by gomaasapi.NewMAAS().

func (*TestMAASObject) Close

func (testMAASObject *TestMAASObject) Close()

Close shuts down the test server.

type TestServer

type TestServer struct {
	*httptest.Server
	// contains filtered or unexported fields
}

A TestServer is an HTTP server listening on a system-chosen port on the local loopback interface, which simulates the behavior of a MAAS server. It is intendend for use in end-to-end HTTP tests using the gomaasapi library.

func NewTestServer

func NewTestServer(version string) *TestServer

NewTestServer starts and returns a new MAAS test server. The caller should call Close when finished, to shut it down.

func (*TestServer) AddBootImage

func (server *TestServer) AddBootImage(nodegroupUUID string, jsonText string)

AddBootImage adds a boot-image object to the specified nodegroup.

func (*TestServer) AddDevice

func (server *TestServer) AddDevice(device *TestDevice)

func (*TestServer) AddFixedAddressRange

func (server *TestServer) AddFixedAddressRange(subnetID uint, ar AddressRange)

AddFixedAddressRange adds an AddressRange to the list of fixed address ranges that subnet stores.

func (*TestServer) AddNodeDetails

func (server *TestServer) AddNodeDetails(systemId, xmlText string)

AddNodeDetails stores node details, expected in XML format.

func (*TestServer) AddTag

func (server *TestServer) AddTag(name, comment string)

AddTah adds a tag to the server.

func (*TestServer) AddZone

func (server *TestServer) AddZone(name, description string)

AddZone adds a physical zone to the server.

func (*TestServer) ChangeNode

func (server *TestServer) ChangeNode(systemId, key, value string)

ChangeNode updates a node with the given key/value.

func (*TestServer) Clear

func (server *TestServer) Clear()

Clear clears all the fake data stored and recorded by the test server (nodes, recorded operations, etc.).

func (*TestServer) ConnectNodeToNetwork

func (server *TestServer) ConnectNodeToNetwork(systemId, name string)

func (*TestServer) ConnectNodeToNetworkWithMACAddress

func (server *TestServer) ConnectNodeToNetworkWithMACAddress(systemId, networkName, macAddress string)

func (*TestServer) Devices

func (server *TestServer) Devices() map[string]*TestDevice

func (*TestServer) Files

func (server *TestServer) Files() map[string]MAASObject

func (*TestServer) IPAddresses

func (server *TestServer) IPAddresses() map[string][]string

IPAddresses returns the map with network names as keys and slices of IP addresses belonging to each network as values.

func (*TestServer) NewFile

func (server *TestServer) NewFile(filename string, filecontent []byte) MAASObject

NewFile creates a file in the test MAAS server.

func (*TestServer) NewIPAddress

func (server *TestServer) NewIPAddress(ipAddress, networkOrSubnet string)

NewIPAddress creates a new static IP address reservation for the given network/subnet and ipAddress. While networks is being deprecated try the given name as both a netowrk and a subnet.

func (*TestServer) NewNetwork

func (server *TestServer) NewNetwork(jsonText string) MAASObject

NewNetwork creates a network in the test MAAS server

func (*TestServer) NewNode

func (server *TestServer) NewNode(jsonText string) MAASObject

NewNode creates a MAAS node. The provided string should be a valid json string representing a map and contain a string value for the key 'system_id'. e.g. `{"system_id": "mysystemid"}`. If one of these conditions is not met, NewNode panics.

func (*TestServer) NewNodegroupInterface

func (server *TestServer) NewNodegroupInterface(uuid, jsonText string) JSONObject

NewNodegroupInterface adds a nodegroup-interface, for the specified nodegroup, in the test MAAS server.

func (*TestServer) NewSpace

func (server *TestServer) NewSpace(spaceJSON io.Reader) *TestSpace

NewSpace creates a space in the test server

func (*TestServer) NewStaticRoute

func (server *TestServer) NewStaticRoute(staticRouteJSON io.Reader) *TestStaticRoute

NewStaticRoute creates a Static Route in the test server.

func (*TestServer) NewSubnet

func (server *TestServer) NewSubnet(subnetJSON io.Reader) *TestSubnet

NewSubnet creates a subnet in the test server

func (*TestServer) NodeOperationRequestValues

func (server *TestServer) NodeOperationRequestValues() map[string][]url.Values

NodeOperationRequestValues returns the map containing the list of the url.Values extracted from the request used when performing operations on nodes.

func (*TestServer) NodeOperations

func (server *TestServer) NodeOperations() map[string][]string

NodeOperations returns the map containing the list of the operations performed for each node.

func (*TestServer) Nodes

func (server *TestServer) Nodes() map[string]MAASObject

Nodes returns a map associating all the nodes' system ids with the nodes' objects.

func (*TestServer) NodesOperationRequestValues

func (server *TestServer) NodesOperationRequestValues() []url.Values

NodesOperationRequestValues returns the list of url.Values extracted from the request used when performing operations at the /nodes/ level.

func (*TestServer) NodesOperations

func (server *TestServer) NodesOperations() []string

NodesOperations returns the list of operations performed at the /nodes/ level.

func (*TestServer) OwnedNodes

func (server *TestServer) OwnedNodes() map[string]bool

OwnedNodes returns a map whose keys represent the nodes that are currently allocated.

func (*TestServer) RemoveIPAddress

func (server *TestServer) RemoveIPAddress(ipAddress string) bool

RemoveIPAddress removes the given existing ipAddress and returns whether it was actually removed.

func (server *TestServer) SetNodeNetworkLink(SystemID string, nodeNetworkInterface NodeNetworkInterface)

SetNodeNetworkLink records that the given node + interface are in subnet

func (*TestServer) SetVersionJSON

func (server *TestServer) SetVersionJSON(json string)

SetVersionJSON sets the JSON response (capabilities) returned from the /version/ endpoint.

func (*TestServer) UpdateSubnet

func (server *TestServer) UpdateSubnet(subnetJSON io.Reader) TestSubnet

UpdateSubnet creates a subnet in the test server

type TestSpace

type TestSpace struct {
	Name        string       `json:"name"`
	Subnets     []TestSubnet `json:"subnets"`
	ResourceURI string       `json:"resource_uri"`
	ID          uint         `json:"id"`
}

TestSpace is the MAAS API space representation

type TestStaticRoute

type TestStaticRoute struct {
	Destination TestSubnet `json:"destination"`
	Source      TestSubnet `json:"source"`
	Metric      uint       `json:"metric"`
	GatewayIP   string     `json:"gateway_ip"`
	ResourceURI string     `json:"resource_uri"`
	ID          uint       `json:"id"`
	// contains filtered or unexported fields
}

TestStaticRoute is the MAAS API Static Route representation

type TestSubnet

type TestSubnet struct {
	DNSServers []string `json:"dns_servers"`
	Name       string   `json:"name"`
	Space      string   `json:"space"`
	VLAN       TestVLAN `json:"vlan"`
	GatewayIP  string   `json:"gateway_ip"`
	CIDR       string   `json:"cidr"`

	ResourceURI        string         `json:"resource_uri"`
	ID                 uint           `json:"id"`
	InUseIPAddresses   []IP           `json:"-"`
	FixedAddressRanges []AddressRange `json:"-"`
}

TestSubnet is the MAAS API subnet representation

type TestVLAN

type TestVLAN struct {
	Name   string `json:"name"`
	Fabric string `json:"fabric"`
	VID    uint   `json:"vid"`

	ResourceURI string `json:"resource_uri"`
	ID          uint   `json:"id"`
}

TestVLAN is the MAAS API VLAN representation

type URLParams

type URLParams struct {
	Values url.Values
}

URLParams wraps url.Values to easily add values, but skipping empty ones.

func NewURLParams

func NewURLParams() *URLParams

NewURLParams allocates a new URLParams type.

func (*URLParams) MaybeAdd

func (p *URLParams) MaybeAdd(name, value string)

MaybeAdd adds the (name, value) pair iff value is not empty.

func (*URLParams) MaybeAddBool

func (p *URLParams) MaybeAddBool(name string, value bool)

MaybeAddBool adds the (name, value) pair iff value is true.

func (*URLParams) MaybeAddInt

func (p *URLParams) MaybeAddInt(name string, value int)

MaybeAddInt adds the (name, value) pair iff value is not zero.

func (*URLParams) MaybeAddMany

func (p *URLParams) MaybeAddMany(name string, values []string)

MaybeAddMany adds the (name, value) for each value in values iff value is not empty.

type UnexpectedError

type UnexpectedError struct {
	errors.Err
}

UnexpectedError is an error for a condition that hasn't been determined.

type UnsupportedVersionError

type UnsupportedVersionError struct {
	errors.Err
}

UnsupportedVersionError refers to calls made to an unsupported api version.

type UpdateInterfaceArgs

type UpdateInterfaceArgs struct {
	Name       string
	MACAddress string
	VLAN       VLAN
}

UpdateInterfaceArgs is an argument struct for calling Interface.Update.

type VLAN

type VLAN interface {
	ID() int
	Name() string
	Fabric() string

	// VID is the VLAN ID. eth0.10 -> VID = 10.
	VID() int
	// MTU (maximum transmission unit) is the largest size packet or frame,
	// specified in octets (eight-bit bytes), that can be sent.
	MTU() int
	DHCP() bool

	PrimaryRack() string
	SecondaryRack() string
}

VLAN represents an instance of a Virtual LAN. VLANs are a common way to create logically separate networks using the same physical infrastructure.

Managed switches can assign VLANs to each port in either a “tagged” or an “untagged” manner. A VLAN is said to be “untagged” on a particular port when it is the default VLAN for that port, and requires no special configuration in order to access.

“Tagged” VLANs (traditionally used by network administrators in order to aggregate multiple networks over inter-switch “trunk” lines) can also be used with nodes in MAAS. That is, if a switch port is configured such that “tagged” VLAN frames can be sent and received by a MAAS node, that MAAS node can be configured to automatically bring up VLAN interfaces, so that the deployed node can make use of them.

A “Default VLAN” is created for every Fabric, to which every new VLAN-aware object in the fabric will be associated to by default (unless otherwise specified).

type Zone

type Zone interface {
	Name() string
	Description() string
}

Zone represents a physical zone that a Machine is in. The meaning of a physical zone is up to you: it could identify e.g. a server rack, a network, or a data centre. Users can then allocate nodes from specific physical zones, to suit their redundancy or performance requirements.

Directories

Path Synopsis
This is an example on how the Go library gomaasapi can be used to interact with a real MAAS server.
This is an example on how the Go library gomaasapi can be used to interact with a real MAAS server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL