gomaasapi: github.com/juju/gomaasapi Index | Files | Directories

package gomaasapi

import "github.com/juju/gomaasapi"


Package Files

blockdevice.go bootresource.go client.go controller.go device.go domain.go enum.go errors.go fabric.go file.go filesystem.go gomaasapi.go interface.go interfaces.go jsonobject.go link.go maas.go maasobject.go machine.go oauth.go partition.go pool.go space.go staticroute.go subnet.go testing.go testservice.go testservice_spaces.go testservice_staticroutes.go testservice_subnets.go testservice_utils.go testservice_vlan.go urlparams.go util.go vlan.go zone.go


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"
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"
const (
    // Capability constants.
    NetworksManagement      = "networks-management"
    StaticIPAddresses       = "static-ipaddresses"
    IPv6DeploymentUbuntu    = "ipv6-deployment-ubuntu"
    DevicesManagement       = "devices-management"
    StorageDeploymentUbuntu = "storage-deployment-ubuntu"
    NetworkDeploymentUbuntu = "network-deployment-ubuntu"


var NotImplemented = errors.New("Not implemented")

func AddAPIVersionToURL Uses

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 Uses

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 Uses

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

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

func IsBadRequestError Uses

func IsBadRequestError(err error) bool

IsBadRequestError returns true if err is a NoMatchError.

func IsCannotCompleteError Uses

func IsCannotCompleteError(err error) bool

IsCannotCompleteError returns true if err is a NoMatchError.

func IsDeserializationError Uses

func IsDeserializationError(err error) bool

IsDeserializationError returns true if err is a DeserializationError.

func IsNoMatchError Uses

func IsNoMatchError(err error) bool

IsNoMatchError returns true if err is a NoMatchError.

func IsPermissionError Uses

func IsPermissionError(err error) bool

IsPermissionError returns true if err is a NoMatchError.

func IsUnexpectedError Uses

func IsUnexpectedError(err error) bool

IsUnexpectedError returns true if err is an UnexpectedError.

func IsUnsupportedVersionError Uses

func IsUnsupportedVersionError(err error) bool

IsUnsupportedVersionError returns true if err is an UnsupportedVersionError.

func JoinURLs Uses

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 Uses

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 Uses

func NewBadRequestError(message string) error

NewBadRequestError constructs a new BadRequestError and sets the location.

func NewCannotCompleteError Uses

func NewCannotCompleteError(message string) error

NewCannotCompleteError constructs a new CannotCompleteError and sets the location.

func NewDeserializationError Uses

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

NewDeserializationError constructs a new DeserializationError and sets the location.

func NewNoMatchError Uses

func NewNoMatchError(message string) error

NewNoMatchError constructs a new NoMatchError and sets the location.

func NewPermissionError Uses

func NewPermissionError(message string) error

NewPermissionError constructs a new PermissionError and sets the location.

func NewUnexpectedError Uses

func NewUnexpectedError(err error) error

NewUnexpectedError constructs a new UnexpectedError and sets the location.

func NewUnsupportedVersionError Uses

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

NewUnsupportedVersionError constructs a new UnsupportedVersionError and sets the location.

func PrettyJsonWriter Uses

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

func SplitVersionedURL Uses

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 Uses

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 Uses

func WrapWithUnsupportedVersionError(err error) error

WrapWithUnsupportedVersionError constructs a new UnsupportedVersionError wrapping the passed error.

type AddFileArgs Uses

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 Uses

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 Uses

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 Uses

type AddressRangeList struct {
    // contains filtered or unexported fields

AddressRangeList is a list of AddressRange

func (*AddressRangeList) Append Uses

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

Append appends a new AddressRange to an AddressRangeList

type AllocateMachineArgs Uses

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 Uses

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 Uses

type BadRequestError struct {

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

type BlockDevice Uses

type BlockDevice interface {

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

    BlockSize() uint64
    UsedSize() uint64

    Partitions() []Partition

BlockDevice represents an entire block device on the machine.

type BootResource Uses

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 Uses

type CannotCompleteError struct {

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

type Client Uses

type Client struct {
    APIURL *url.URL
    Signer OAuthSigner

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

func NewAnonymousClient Uses

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 Uses

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 Uses

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

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

func (Client) Get Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type Controller interface {

    // 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)

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 Uses

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 Uses

type ControllerArgs struct {
    BaseURL string
    APIKey  string

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

type CreateDeviceArgs Uses

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

CreateDeviceArgs is a argument struct for passing information into CreateDevice.

type CreateInterfaceArgs Uses

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).
    // 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 Uses

func (a *CreateInterfaceArgs) Validate() error

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

type CreateMachineDeviceArgs Uses

type CreateMachineDeviceArgs struct {
    Hostname      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 Uses

func (a *CreateMachineDeviceArgs) Validate() error

Validate ensures that all required values are non-emtpy.

type CreateSpace Uses

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

CreateSpace is used to create new spaces on the server.

type CreateStaticRoute Uses

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 Uses

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 Uses

type DeserializationError struct {

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

type Device Uses

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 Uses

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 Uses

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

type Fabric Uses

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 Uses

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 Uses

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 Uses

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

IP is an enhanced net.IP

func IPFromInt64 Uses

func IPFromInt64(v uint64) IP

IPFromInt64 creates a new IP from a uint64 IP address representation

func IPFromNetIP Uses

func IPFromNetIP(netIP net.IP) IP

IPFromNetIP creates a IP from a net.IP.

func IPFromString Uses

func IPFromString(v string) IP

IPFromString creates a new IP from a string IP address representation

func (*IP) SetUInt64 Uses

func (ip *IP) SetUInt64(v uint64)

SetUInt64 sets the IP value to v

func (IP) String Uses

func (ip IP) String() string

func (IP) To16 Uses

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 Uses

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 Uses

func (ip IP) UInt64() uint64

UInt64 returns a uint64 holding the IP address

type Interface Uses

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

    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 Uses

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 Uses

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 Uses

func (a *InterfaceSpec) String() string

String returns the interface spec as MaaS requires it.

func (*InterfaceSpec) Validate Uses

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 Uses

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 Uses

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

JSONObjectFromStruct takes a struct and converts it to a JSONObject

func Parse Uses

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

Parse a JSON blob into a JSONObject.

func (JSONObject) GetArray Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func NewMAAS(client Client) *MAASObject

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

func (MAASObject) CallGet Uses

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

CallGet invokes an idempotent API method on this object.

func (MAASObject) CallPost Uses

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

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

func (MAASObject) CallPostFiles Uses

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 Uses

func (obj MAASObject) Delete() error

Delete removes this object on the API.

func (MAASObject) Get Uses

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

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

func (MAASObject) GetField Uses

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

GetField extracts a string field from this MAAS object.

func (MAASObject) GetMap Uses

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

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

func (MAASObject) GetSubObject Uses

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 Uses

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

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

func (MAASObject) Post Uses

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 Uses

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 Uses

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 Uses

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 Uses

type Machine interface {

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

    OperatingSystem() string
    DistroSeries() string
    Architecture() string
    Memory() int
    CPUCount() int

    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 Uses

type MachinesArgs struct {
    Hostnames    []string
    MACAddresses []string
    SystemIDs    []string
    Domain       string
    Zone         string
    Pool         string
    AgentName    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 Uses

type NoMatchError struct {

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 Uses

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

Node represents a node

type NodeNetworkInterface Uses

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

NodeNetworkInterface represents a network interface attached to a node

type OAuthSigner Uses

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

func NewPlainTestOAuthSigner Uses

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

type OAuthToken Uses

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

type OwnerDataHolder Uses

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 Uses

type Partition interface {

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

type PermissionError Uses

type PermissionError struct {

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

type Pool Uses

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

Pool is just a logical separation of resources.

type PostedVLAN Uses

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

PostedVLAN is the MAAS API posted VLAN representation

type ReleaseMachinesArgs Uses

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 Uses

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 Uses

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 Uses

type SimpleTestServer struct {
    // contains filtered or unexported fields

func NewSimpleServer Uses

func NewSimpleServer() *SimpleTestServer

func (*SimpleTestServer) AddDeleteResponse Uses

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

func (*SimpleTestServer) AddGetResponse Uses

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

func (*SimpleTestServer) AddPostResponse Uses

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

func (*SimpleTestServer) AddPutResponse Uses

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

func (*SimpleTestServer) LastNRequests Uses

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

func (*SimpleTestServer) LastRequest Uses

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

func (*SimpleTestServer) RequestCount Uses

func (s *SimpleTestServer) RequestCount() int

func (*SimpleTestServer) ResetRequests Uses

func (s *SimpleTestServer) ResetRequests()

type Space Uses

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

Space is a name for a collection of Subnets.

type StartArgs Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (s *StorageSpec) String() string

String returns the string representation of the storage spec.

func (*StorageSpec) Validate Uses

func (s *StorageSpec) Validate() error

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

type Subnet Uses

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

    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 Uses

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 TestDevice Uses

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 Uses

type TestMAASObject struct {
    TestServer *TestServer

TestMAASObject is a fake MAAS server MAASObject.

func NewTestMAAS Uses

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 Uses

func (testMAASObject *TestMAASObject) Close()

Close shuts down the test server.

type TestServer Uses

type TestServer struct {
    // 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 Uses

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 Uses

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

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

func (*TestServer) AddDevice Uses

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

func (*TestServer) AddFixedAddressRange Uses

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 Uses

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

AddNodeDetails stores node details, expected in XML format.

func (*TestServer) AddTag Uses

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

AddTah adds a tag to the server.

func (*TestServer) AddZone Uses

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

AddZone adds a physical zone to the server.

func (*TestServer) ChangeNode Uses

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

ChangeNode updates a node with the given key/value.

func (*TestServer) Clear Uses

func (server *TestServer) Clear()

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

func (*TestServer) ConnectNodeToNetwork Uses

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

func (*TestServer) ConnectNodeToNetworkWithMACAddress Uses

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

func (*TestServer) Devices Uses

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

func (*TestServer) Files Uses

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

func (*TestServer) IPAddresses Uses

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 Uses

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

NewFile creates a file in the test MAAS server.

func (*TestServer) NewIPAddress Uses

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 Uses

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

NewNetwork creates a network in the test MAAS server

func (*TestServer) NewNode Uses

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 Uses

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 Uses

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

NewSpace creates a space in the test server

func (*TestServer) NewStaticRoute Uses

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

NewStaticRoute creates a Static Route in the test server.

func (*TestServer) NewSubnet Uses

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

NewSubnet creates a subnet in the test server

func (*TestServer) NodeOperationRequestValues Uses

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 Uses

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

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

func (*TestServer) Nodes Uses

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

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

func (*TestServer) NodesOperationRequestValues Uses

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 Uses

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

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

func (*TestServer) OwnedNodes Uses

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

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

func (*TestServer) RemoveIPAddress Uses

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 Uses

func (server *TestServer) SetVersionJSON(json string)

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

func (*TestServer) UpdateSubnet Uses

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

UpdateSubnet creates a subnet in the test server

type TestSpace Uses

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 Uses

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 Uses

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 Uses

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 Uses

type URLParams struct {
    Values url.Values

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

func NewURLParams Uses

func NewURLParams() *URLParams

NewURLParams allocates a new URLParams type.

func (*URLParams) MaybeAdd Uses

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

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

func (*URLParams) MaybeAddBool Uses

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

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

func (*URLParams) MaybeAddInt Uses

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

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

func (*URLParams) MaybeAddMany Uses

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 Uses

type UnexpectedError struct {

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

type UnsupportedVersionError Uses

type UnsupportedVersionError struct {

UnsupportedVersionError refers to calls made to an unsupported api version.

type UpdateInterfaceArgs Uses

type UpdateInterfaceArgs struct {
    Name       string
    MACAddress string
    VLAN       VLAN

UpdateInterfaceArgs is an argument struct for calling Interface.Update.

type VLAN Uses

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 Uses

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.


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

Package gomaasapi imports 30 packages (graph) and is imported by 35 packages. Updated 2019-08-26. Refresh now. Tools for package owners.