gmaw

package
v0.0.0-...-e443136 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

gmaw is a wrapper (read: adapter) for github.com/juju/gomaasapi to make it

compatible with the client interfaces defined in and expected by the adjacent maas package. See that package for conventions.

While this package can be used alone, the exported types are designed to be consumed by their analog in the maas package. This package is just a vehicle for the maas package to access the MAAS API.

Usage

First, use the provided GetClient() or the gomaasapi equivalent to create a "global" gomaasapi.MAASObject for consumption by the types defined in this package. Next, use the New<T> function for the type that correlates to the endpoint you wish to call to return a usable type, and then start calling methods on the type to perform operations via your MAAS API.

``` // Get a gomaasapi client myMAAS, err := gmaw.GetClient("http://example/MAAS/", "supersecr3t", "2.0")

if err != nil {
	log.Fatal(err)
}

// Get the Machine endpoint myMachineClient := gmaw.NewMachine(myMAAS)

// ...And use it with the maas package myChassis := maas.NewMachineManager('my_system_id', myMachineClient)

if err := myChassis.Deploy(maas.MachineDeployParams{}); err != nil {
	log.Fatal("Likely got a non-200 response from MAAS API")
}

// Or do it cowboy style yourMAAS, _ := gmaw.GetClient("http://example/MAAS/", "supersecr3t", "2.0") res, err := gmaw.NewMachineManager(myMAAS).Deploy('your_sid', maas.MachineDeployParams{}) ```

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClient

func GetClient(apiURL, apiKey, apiVersion string) (*gomaasapi.MAASObject, error)

GetClient is a convenience function to create a new gomaasapi client. It calls the NewAuthenticatedClient function with the provided credentials, and calls NewMAAS() on the returned value to create the resulting MAASObject. A non-nil error will be from GetAuthenticatedClient, and the returned client can be used with the other types in this package.

Types

type Client

type Client struct {
	*gomaasapi.MAASObject
}

func (Client) Get

func (c Client) Get(op string, params url.Values, f func([]byte) error) error

func (Client) GetSubObject

func (c Client) GetSubObject(name string) Client

func (Client) Post

func (c Client) Post(op string, params url.Values, f func([]byte) error) error

func (Client) Put

func (c Client) Put(params url.Values, f func([]byte) error) error

type MAASServer

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

MAASServer provides methods for the MMAS Server operations in the MaaS API. This type should be instantiated via NewMAASServer(). It fulfills the api.MAASServer interface.

func NewMAASServer

func NewMAASServer(client *gomaasapi.MAASObject) *MAASServer

NewMAASServer configures a new MAASServer.

func (*MAASServer) Get

func (m *MAASServer) Get(name string) (res string, err error)

Get returns the value of the configuration key <name>. This function returns an error if the gomaasapi returns an error.

func (*MAASServer) Post

func (m *MAASServer) Post(name, value string) (err error)

Post sets a configuration parameter <name> to <value>. This function returns an error if the gomaasapi returns an error.

type Machine

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

Machine implements the maas.MachineFetcher interface. It exposes the functionality of the MAAS Machine endpoint (eg machines/{systemid}), and can be used with as many machines as desired since each method call takes the systemID as a parameter. Multiple instances of this type are only necessary to support multiple clients.

func NewMachine

func NewMachine(client *gomaasapi.MAASObject) *Machine

NewMachine returns a pointer to a Machine.

func (*Machine) Commission

func (m *Machine) Commission(systemID string, params maas.MachineCommissionParams) ([]byte, error)

Commission fulfills the maas.MachineFetcher interface

func (*Machine) Deploy

func (m *Machine) Deploy(systemID string, params *maas.MachineDeployParams) ([]byte, error)

Deploy fulfills the maas.MachineFetcher interface

func (*Machine) Get

func (m *Machine) Get(systemID string) ([]byte, error)

Get fulfills the maas.MachineFetcher interface

func (*Machine) Lock

func (m *Machine) Lock(systemID, comment string) ([]byte, error)

Lock fulfills the maas.MachineFetcher interface

type Machines

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

Machines implements the maas.MachinesFetcher interface.

func NewMachines

func NewMachines(client *gomaasapi.MAASObject) *Machines

NewMachines returns a pointer to a Machines.

func (*Machines) Allocate

func (m *Machines) Allocate(params *maas.MachinesAllocateParams) ([]byte, error)

Allocate fulfills the maas.MachinesFetcher interface

func (*Machines) Release

func (m *Machines) Release(systemIDs []string, comment string) error

Release fulfills the maas.MachinesFetcher interface

type NetworkInterface

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

NetworkInterface provides methods for the Interface operations in the MaaS API. This type should be instantiated via NewNetworkInterface(). It fulfills the api.NetworkInterface interface.

func NewNetworkInterface

func NewNetworkInterface(client *gomaasapi.MAASObject) *NetworkInterface

NewNetworkInterface configures a new NetworkInterface.

func (*NetworkInterface) AddTag

func (i *NetworkInterface) AddTag(systemID string, id int, tag string) (ifc *entity.NetworkInterface, err error)

AddTag adds an additional tag to the interface. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) Delete

func (i *NetworkInterface) Delete(systemID string, id int) error

Delete the selected interface. This function returns an error if the gomaasapi returns an error.

func (*NetworkInterface) Disconnect

func (i *NetworkInterface) Disconnect(systemID string, id int) (ifc *entity.NetworkInterface, err error)

Disconnect the interface with <id> on <systemID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) Get

func (i *NetworkInterface) Get(systemID string, id int) (ifc *entity.NetworkInterface, err error)

Get information about the interface with <id> on <systemID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) LinkSubnet

func (i *NetworkInterface) LinkSubnet(systemID string, id int,
	p *params.NetworkInterfaceLink) (ifc *entity.NetworkInterface, err error)

LinkSubnet links the interface with <id> on <systemID> as described in <params>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) Put

func (i *NetworkInterface) Put(systemID string, id int, p interface{}) (ifc *entity.NetworkInterface, err error)

Put updates the interface configuration with <params>. The params argument is one of params.NetworkInterface{Bond,Bridge,Physical,VLAN}, depending on the type of interface being updated. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) RemoveTag

func (i *NetworkInterface) RemoveTag(systemID string, id int, tag string) (ifc *entity.NetworkInterface, err error)

RemoveTag removes the <tag> tag from the interface This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) SetDefaultGateway

func (i *NetworkInterface) SetDefaultGateway(systemID string, id,
	linkID int) (ifc *entity.NetworkInterface, err error)

SetDefaultGateway sets interface <id> to be the default gateway for <systemID>. If this interface has more than one subnet with a gateway IP in the same IP address family then specifying the ID of the link on this interface is required. Set the linkID to 0 to omit this parameter. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterface) UnlinkSubnet

func (i *NetworkInterface) UnlinkSubnet(systemID string, id, linkID int) (ifc *entity.NetworkInterface, err error)

Unlink subnet removes the link between interface <id> and link <linkID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

type NetworkInterfaces

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

NetworkInterfaces provides methods for the Interfaces operations in the MaaS API. This type should be instantiated via NewNetworkInterfaces(). It fulfills the api.NetworkInterfaces interface.

func NewNetworkInterfaces

func NewNetworkInterfaces(client *gomaasapi.MAASObject) *NetworkInterfaces

NewNetworkInterfaces configures a new NetworkInterfaces.

func (*NetworkInterfaces) CreateBond

func (i *NetworkInterfaces) CreateBond(systemID string,
	p *params.NetworkInterfaceBond) (ifc *entity.NetworkInterface, err error)

CreateBond creates a new bond interface on <systemID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterfaces) CreateBridge

func (i *NetworkInterfaces) CreateBridge(systemID string,
	p *params.NetworkInterfaceBridge) (ifc *entity.NetworkInterface, err error)

CreateBridge creates a new bridge interface on <systemID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterfaces) CreatePhysical

func (i *NetworkInterfaces) CreatePhysical(systemID string,
	p *params.NetworkInterfacePhysical) (ifc *entity.NetworkInterface, err error)

CreatePhysical creates a new physical interface on <systemID>'s <params.MACAddress> interface. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterfaces) CreateVLAN

func (i *NetworkInterfaces) CreateVLAN(systemID string,
	p *params.NetworkInterfaceVLAN) (ifc *entity.NetworkInterface, err error)

CreateVLAN creates a new VLAN interface on <systemID>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*NetworkInterfaces) Get

func (i *NetworkInterfaces) Get(systemID string) (ifcs []entity.NetworkInterface, err error)

Get returns information about all of <systemID>'s configured interfaces. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

type RackControllers

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

RackControllers provides methods for the Rack Controllers operations in the MaaS API. This type should be instantiated via NewRackControllers(). It fulfills the api.RackControllers interface.

func NewRackControllers

func NewRackControllers(client *gomaasapi.MAASObject) *RackControllers

NewRackControllers configures a new RackControllers.

func (*RackControllers) Get

Get returns information about configured rack controllers. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

type Subnet

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

Subnet provides methods for the Subnet operations in the MaaS API. This type should be instantiated via NewSubnet(). It fulfills the api.Subnet interface.

func NewSubnet

func NewSubnet(client *gomaasapi.MAASObject) *Subnet

NewSubnet configures a new Subnet.

func (*Subnet) Delete

func (s *Subnet) Delete(id int) error

Delete removes a subnet. This function returns an error if the gomaasapi returns an error.

func (*Subnet) Get

func (s *Subnet) Get(id int) (sn *entity.Subnet, err error)

Get returns information about a subnet. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnet) GetIPAddresses

func (s *Subnet) GetIPAddresses(id int, withUsername, withSummary bool) (addrs []subnet.IPAddress, err error)

GetIPAddresses returns information about the IP addresses in the subnet. The withUsername and withSummary parameters can be set to false to suppress the display of usernames and nodes/BMCs/DNSRRs, respectively, associated with each IP. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnet) GetReservedIPRanges

func (s *Subnet) GetReservedIPRanges(id int) (ranges []subnet.ReservedIPRange, err error)

GetReservedIPRanges returns a list of reserved IP ranges. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnet) GetStatistics

func (s *Subnet) GetStatistics(id int, includeRanges, includeSuggestions bool) (stats *subnet.Statistics, err error)

GetStatistics returns some statistics about the subnet. If includeRanges is true, the response will include detailed information about the usage of the range. Setting includeSuggestions includes the suggested gateway and dynamic range for this subnet, if it were to be configured. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnet) GetUnreservedIPRanges

func (s *Subnet) GetUnreservedIPRanges(id int) (ranges []subnet.IPRange, err error)

GetUnreservedIPRanges returns a list of unreserved IP ranges. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnet) Put

func (s *Subnet) Put(id int, p *params.Subnet) (sn *entity.Subnet, err error)

Put updates the configuration for a subnet. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

type Subnets

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

Subnets provides methods for the Subnets operations in the MaaS API. This type should be instantiated via NewSubnets(). It fulfills the api.Subnets interface.

func NewSubnets

func NewSubnets(client *gomaasapi.MAASObject) *Subnets

NewSubnets configures a new Subnets.

func (*Subnets) Get

func (s *Subnets) Get() (subnets []entity.Subnet, err error)

Get returns information about all of the configured subnets. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*Subnets) Post

func (s *Subnets) Post(p *params.Subnet) (subnet *entity.Subnet, err error)

Post creates a new subnet and returns information about the new subnet. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

type VLANs

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

VLANs provides methods for the vlans operations in the MaaS API. This type should be instantiated via NewVLANs(). It fulfills the api.VLANs interface.

func NewVLANs

func NewVLANs(client *gomaasapi.MAASObject) *VLANs

NewVLANs configures a new VLANs.

func (*VLANs) Get

func (v *VLANs) Get(fabricID int) (vlans []entity.VLAN, err error)

Get returns information about all of the configured VLANs for <fabric>. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

func (*VLANs) Post

func (v *VLANs) Post(fabricID int, p *params.VLAN) (vlan *entity.VLAN, err error)

Post creates a new VLAN and returns information about the new VLAN. This function returns an error if the gomaasapi returns an error or if the response cannot be decoded.

Jump to

Keyboard shortcuts

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