metalgo

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 23 Imported by: 23

README

metal-go

Actions GoDoc Go Report Card codecov License

Metal Go API Client.

Documentation

Index

Constants

View Source
const (
	// IPTypeEphemeral if specified a ip gets released after usage
	IPTypeEphemeral = "ephemeral"
	// IPTypeStatic if specified a ip must be released manually
	IPTypeStatic = "static"
)
View Source
const (
	// TagClusterQualifier identifies the cluster
	TagClusterQualifier = "clusterid"
	// TagServiceQualifier identifies the service
	TagServiceQualifier = "service"
	// TagNamespaceQualifier identifies the namespace
	TagNamespaceQualifier = "namespace"

	// TagClusterPrefix the prefix of the tag used to identify a cluster
	TagClusterPrefix = "cluster.metal-pod.io/" + TagClusterQualifier

	// TagServicePrefix the prefix of the tag used to identify services
	TagServicePrefix = TagClusterPrefix + "/" + TagNamespaceQualifier + "/" + TagServiceQualifier

	// TagMachineQualifier identifies the machine
	TagMachineQualifier = "machineid"

	// TagMachinePrefix the prefix of the tag used to identify a machine
	TagMachinePrefix = "metal.metal-pod.io/" + TagMachineQualifier
)

Variables

This section is empty.

Functions

func BuildServiceTag

func BuildServiceTag(clusterID string, namespace, serviceName string) string

BuildServiceTag constructs the service tag for the given cluster and service

func BuildServiceTagClusterPrefix

func BuildServiceTagClusterPrefix(clusterID string) string

BuildServiceTagClusterPrefix constructs the prefix of the service tag that identify all services of a cluster

func TagIsMachine

func TagIsMachine(tag string) bool

TagIsMachine returns true if the given tag is a machinetag.

func TagIsMemberOfCluster

func TagIsMemberOfCluster(tag, clusterID string) bool

TagIsMemberOfCluster returns true of the given tag is a clustertag and clusterID matches.

Types

type BootConfig

type BootConfig struct {
	Commandline string
	Imageurl    string
	Kernelurl   string
}

BootConfig in the partition

type ChassisIdentifyLEDPowerResponse

type ChassisIdentifyLEDPowerResponse struct {
	Machine *models.V1MachineResponse
}

ChassisIdentifyLEDPowerResponse contains the machine LED power result

type Driver

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

Driver holds the client connection to the metal api

func NewDriver

func NewDriver(rawurl, bearer, hmac string) (*Driver, error)

NewDriver Create a new Driver for Metal to given url

func (*Driver) ChassisIdentifyLEDPowerOff

func (d *Driver) ChassisIdentifyLEDPowerOff(machineID, description string) (*ChassisIdentifyLEDPowerResponse, error)

ChassisIdentifyLEDPowerOff powers off the given machine

func (*Driver) ChassisIdentifyLEDPowerOn

func (d *Driver) ChassisIdentifyLEDPowerOn(machineID, description string) (*ChassisIdentifyLEDPowerResponse, error)

ChassisIdentifyLEDPowerOn powers on the given machine

func (*Driver) FirewallCreate

func (d *Driver) FirewallCreate(fcr *FirewallCreateRequest) (*FirewallCreateResponse, error)

FirewallCreate will create a single metal machine

func (*Driver) FirewallFind

func (d *Driver) FirewallFind(ffr *FirewallFindRequest) (*FirewallListResponse, error)

FirewallFind will search for firewalls for given criteria

func (*Driver) FirewallGet

func (d *Driver) FirewallGet(machineID string) (*FirewallGetResponse, error)

FirewallGet will only return one machine

func (*Driver) FirewallList

func (d *Driver) FirewallList() (*FirewallListResponse, error)

FirewallList will list all machines

func (*Driver) IPAllocate

func (d *Driver) IPAllocate(iar *IPAllocateRequest) (*IPDetailResponse, error)

IPAllocate allocates an IP in a network for a project

func (*Driver) IPFind

func (d *Driver) IPFind(ifr *IPFindRequest) (*IPListResponse, error)

IPFind returns all ips that match given properties

func (*Driver) IPFree

func (d *Driver) IPFree(id string) (*IPDetailResponse, error)

IPFree frees an IP

func (*Driver) IPGet

func (d *Driver) IPGet(ipaddress string) (*IPDetailResponse, error)

IPGet gets a given IP

func (*Driver) IPList

func (d *Driver) IPList() (*IPListResponse, error)

IPList lists all IPs

func (*Driver) IPUpdate

func (d *Driver) IPUpdate(iur *IPUpdateRequest) (*IPDetailResponse, error)

IPUpdate updates an IP

func (*Driver) ImageCreate

func (d *Driver) ImageCreate(icr ImageCreateRequest) (*ImageCreateResponse, error)

ImageCreate create a image

func (*Driver) ImageDelete

func (d *Driver) ImageDelete(imageID string) (*ImageGetResponse, error)

ImageDelete return a image

func (*Driver) ImageGet

func (d *Driver) ImageGet(imageID string) (*ImageGetResponse, error)

ImageGet return a image

func (*Driver) ImageList

func (d *Driver) ImageList() (*ImageListResponse, error)

ImageList return all machine images

func (*Driver) ImageUpdate

func (d *Driver) ImageUpdate(icr ImageCreateRequest) (*ImageCreateResponse, error)

ImageUpdate create a image

func (*Driver) MachineBootBios

func (d *Driver) MachineBootBios(machineID string) (*MachineBiosResponse, error)

MachineBootBios boots given machine into BIOS

func (*Driver) MachineCreate

func (d *Driver) MachineCreate(mcr *MachineCreateRequest) (*MachineCreateResponse, error)

MachineCreate creates a single metal machine

func (*Driver) MachineDelete

func (d *Driver) MachineDelete(machineID string) (*MachineDeleteResponse, error)

MachineDelete deletes a single metal machine

func (*Driver) MachineFind

func (d *Driver) MachineFind(mfr *MachineFindRequest) (*MachineListResponse, error)

MachineFind lists all machines that match the given properties

func (*Driver) MachineGet

func (d *Driver) MachineGet(id string) (*MachineGetResponse, error)

MachineGet returns the machine with the given ID

func (*Driver) MachineIPMIGet

func (d *Driver) MachineIPMIGet(id string) (*MachineIPMIGetResponse, error)

MachineIPMIGet returns the machine with the given ID including IPMI data

func (*Driver) MachineIPMIList

func (d *Driver) MachineIPMIList(mfr *MachineFindRequest) (*MachineIPMIListResponse, error)

MachineIPMIList returns the machine list of the given search query including IPMI data

func (*Driver) MachineList

func (d *Driver) MachineList() (*MachineListResponse, error)

MachineList lists all machines

func (*Driver) MachineLock

func (d *Driver) MachineLock(machineID, description string) (*MachineStateResponse, error)

MachineLock locks a machine to prevent it from being destroyed

func (*Driver) MachinePowerOff

func (d *Driver) MachinePowerOff(machineID string) (*MachinePowerResponse, error)

MachinePowerOff powers off the given machine

func (*Driver) MachinePowerOn

func (d *Driver) MachinePowerOn(machineID string) (*MachinePowerResponse, error)

MachinePowerOn powers on the given machine

func (*Driver) MachinePowerReset

func (d *Driver) MachinePowerReset(machineID string) (*MachinePowerResponse, error)

MachinePowerReset power-resets the given machine

func (*Driver) MachineReserve

func (d *Driver) MachineReserve(machineID, description string) (*MachineStateResponse, error)

MachineReserve reserves a machine for single allocation

func (*Driver) MachineUnLock

func (d *Driver) MachineUnLock(machineID string) (*MachineStateResponse, error)

MachineUnLock unlocks a machine

func (*Driver) MachineUnReserve

func (d *Driver) MachineUnReserve(machineID string) (*MachineStateResponse, error)

MachineUnReserve unreserves a machine

func (*Driver) NetworkAddPrefix

func (d *Driver) NetworkAddPrefix(nur *NetworkUpdateRequest) (*NetworkDetailResponse, error)

NetworkAddPrefix adds a prefix to a network

func (*Driver) NetworkAllocate

func (d *Driver) NetworkAllocate(ncr *NetworkAllocateRequest) (*NetworkDetailResponse, error)

NetworkAllocate creates a new network

func (*Driver) NetworkCreate

func (d *Driver) NetworkCreate(ncr *NetworkCreateRequest) (*NetworkDetailResponse, error)

NetworkCreate creates a new network

func (*Driver) NetworkFind

func (d *Driver) NetworkFind(nfr *NetworkFindRequest) (*NetworkListResponse, error)

NetworkFind returns all networks that match given properties

func (*Driver) NetworkFree

func (d *Driver) NetworkFree(id string) (*NetworkDetailResponse, error)

NetworkFree frees a network

func (*Driver) NetworkGet

func (d *Driver) NetworkGet(id string) (*NetworkGetResponse, error)

NetworkGet returns the network with the given ID

func (*Driver) NetworkList

func (d *Driver) NetworkList() (*NetworkListResponse, error)

NetworkList returns all networks

func (*Driver) NetworkRemovePrefix

func (d *Driver) NetworkRemovePrefix(nur *NetworkUpdateRequest) (*NetworkDetailResponse, error)

NetworkRemovePrefix removes a prefix from a network

func (*Driver) NetworkUpdate

func (d *Driver) NetworkUpdate(ncr *NetworkCreateRequest) (*NetworkDetailResponse, error)

NetworkUpdate updates a network

func (*Driver) PartitionCapacity

func (d *Driver) PartitionCapacity() (*PartitionCapacityResponse, error)

PartitionCapacity return a partition

func (*Driver) PartitionCreate

func (d *Driver) PartitionCreate(pcr PartitionCreateRequest) (*PartitionCreateResponse, error)

PartitionCreate create a partition

func (*Driver) PartitionDelete

func (d *Driver) PartitionDelete(partitionID string) (*PartitionGetResponse, error)

PartitionDelete return a partition

func (*Driver) PartitionGet

func (d *Driver) PartitionGet(partitionID string) (*PartitionGetResponse, error)

PartitionGet return a partition

func (*Driver) PartitionList

func (d *Driver) PartitionList() (*PartitionListResponse, error)

PartitionList return all partitions

func (*Driver) PartitionUpdate

func (d *Driver) PartitionUpdate(pcr PartitionCreateRequest) (*PartitionCreateResponse, error)

PartitionUpdate create a partition

func (*Driver) ProjectFind

func (d *Driver) ProjectFind(pfr ProjectFindRequest) (*ProjectListResponse, error)

ProjectFind return projects by given findRequest

func (*Driver) ProjectGet

func (d *Driver) ProjectGet(projectID string) (*ProjectGetResponse, error)

ProjectGet return a Project

func (*Driver) ProjectList

func (d *Driver) ProjectList() (*ProjectListResponse, error)

ProjectList return all projects

func (*Driver) SizeCreate

func (d *Driver) SizeCreate(pcr SizeCreateRequest) (*SizeCreateResponse, error)

SizeCreate create a size

func (*Driver) SizeDelete

func (d *Driver) SizeDelete(sizeID string) (*SizeGetResponse, error)

SizeDelete return a size

func (*Driver) SizeGet

func (d *Driver) SizeGet(sizeID string) (*SizeGetResponse, error)

SizeGet return a size

func (*Driver) SizeList

func (d *Driver) SizeList() (*SizeListResponse, error)

SizeList return all machine sizes

func (*Driver) SizeTry

func (d *Driver) SizeTry(cores int32, memory, storage uint64) (*SizeTryResponse, error)

SizeTry will return the chosen size with given Hardware specs.

func (*Driver) SizeUpdate

func (d *Driver) SizeUpdate(pcr SizeCreateRequest) (*SizeCreateResponse, error)

SizeUpdate create a size

func (*Driver) SwitchList

func (d *Driver) SwitchList() (*SwitchListResponse, error)

SwitchList return all switches

type FirewallCreateRequest

type FirewallCreateRequest struct {
	MachineCreateRequest
}

FirewallCreateRequest contains data for a machine creation

type FirewallCreateResponse

type FirewallCreateResponse struct {
	Firewall *models.V1FirewallResponse
}

FirewallCreateResponse is returned when a machine was created

type FirewallFindRequest

type FirewallFindRequest struct {
	MachineFindRequest
}

FirewallFindRequest contains criteria for a machine listing

type FirewallGetResponse

type FirewallGetResponse struct {
	Firewall *models.V1FirewallResponse
}

FirewallGetResponse contains the machine get result

type FirewallListResponse

type FirewallListResponse struct {
	Firewalls []*models.V1FirewallResponse
}

FirewallListResponse contains the machine list result

type IPAllocateRequest

type IPAllocateRequest struct {

	// SpecificIP tries to acquire this ip.
	// Required: false
	IPAddress string `json:"ipaddress"`

	// a description for this entity
	Description string `json:"description,omitempty"`

	// the readable name
	Name string `json:"name,omitempty"`

	// the network this ip acquire request belongs to, required.
	// Required: true
	Networkid string `json:"networkid"`

	// the project this ip acquire request belongs to, required.
	// Required: true
	Projectid string `json:"projectid"`

	// the machine this ip acquire request belongs to
	Machineid *string `json:"machineid"`

	// the type of the ip
	Type string `json:"type,omitempty"`

	// tags for the ip
	Tags []string `json:"tags,omitempty"`
}

IPAllocateRequest is the request to allocate an IP

type IPDetailResponse

type IPDetailResponse struct {
	IP *models.V1IPResponse
}

IPDetailResponse is the response to an IP detail request.

type IPFindRequest

type IPFindRequest struct {
	IPAddress        *string
	ProjectID        *string
	ParentPrefixCidr *string
	NetworkID        *string
	MachineID        *string
	Type             *string
	Tags             []string
}

IPFindRequest contains criteria for a ip listing

type IPListResponse

type IPListResponse struct {
	IPs []*models.V1IPResponse
}

IPListResponse is the response when ips are listed

type IPUpdateRequest

type IPUpdateRequest struct {
	// the ip address for this ip update request.
	IPAddress string `json:"ipaddress"`
	// a description for this entity
	Description string `json:"description,omitempty"`
	// the readable name
	Name string `json:"name,omitempty"`
	// the type of the ip
	Type string `json:"type,omitempty"`
	// tags for the ip
	Tags []string `json:"tags,omitempty"`
}

IPUpdateRequest is the request to update an IP

type ImageCreateRequest

type ImageCreateRequest struct {
	ID          string
	Name        string
	Description string
	URL         string
	Features    []string
}

ImageCreateRequest is the response of a ImageList action

type ImageCreateResponse

type ImageCreateResponse struct {
	Image *models.V1ImageResponse
}

ImageCreateResponse is the response of a ImageList action

type ImageGetResponse

type ImageGetResponse struct {
	Image *models.V1ImageResponse
}

ImageGetResponse is the response of a ImageList action

type ImageListResponse

type ImageListResponse struct {
	Image []*models.V1ImageResponse
}

ImageListResponse is the response of a ImageList action

type MachineAllocationNetwork

type MachineAllocationNetwork struct {
	Autoacquire bool
	NetworkID   string
}

MachineAllocationNetwork contains configuration for machine networks

type MachineBiosResponse

type MachineBiosResponse struct {
	Machine *models.V1MachineResponse
}

MachineBiosResponse contains the machine bios result

type MachineCreateRequest

type MachineCreateRequest struct {
	Description   string
	Hostname      string
	Name          string
	UserData      string
	Size          string
	Project       string
	Partition     string
	Image         string
	Tags          []string
	SSHPublicKeys []string
	UUID          string
	Networks      []MachineAllocationNetwork
	IPs           []string
}

MachineCreateRequest contains data for a machine creation

type MachineCreateResponse

type MachineCreateResponse struct {
	Machine *models.V1MachineResponse
}

MachineCreateResponse is returned when a machine was created

type MachineDeleteResponse

type MachineDeleteResponse struct {
	Machine *models.V1MachineResponse
}

MachineDeleteResponse contains the machine delete result

type MachineFindRequest

type MachineFindRequest struct {
	ID          *string
	Name        *string
	PartitionID *string
	SizeID      *string
	RackID      *string
	Liveliness  *string
	Tags        []string

	// allocation
	AllocationName      *string
	AllocationProject   *string
	AllocationImageID   *string
	AllocationHostname  *string
	AllocationSucceeded *bool

	// network
	NetworkIDs                 []string
	NetworkPrefixes            []string
	NetworkIPs                 []string
	NetworkDestinationPrefixes []string
	NetworkVrfs                []int64
	NetworkPrivate             *bool
	NetworkASNs                []int64
	NetworkNat                 *bool
	NetworkUnderlay            *bool

	// hardware
	HardwareMemory   *int64
	HardwareCPUCores *int64

	// nics
	NicsMacAddresses         []string
	NicsNames                []string
	NicsVrfs                 []string
	NicsNeighborMacAddresses []string
	NicsNeighborNames        []string
	NicsNeighborVrfs         []string

	// disks
	DiskNames []string
	DiskSizes []int64

	// state
	StateValue *string

	// ipmi
	IpmiAddress    *string
	IpmiMacAddress *string
	IpmiUser       *string
	IpmiInterface  *string

	// fru
	FruChassisPartNumber   *string
	FruChassisPartSerial   *string
	FruBoardMfg            *string
	FruBoardMfgSerial      *string
	FruBoardPartNumber     *string
	FruProductManufacturer *string
	FruProductPartNumber   *string
	FruProductSerial       *string
}

MachineFindRequest contains criteria for a machine listing

type MachineGetResponse

type MachineGetResponse struct {
	Machine *models.V1MachineResponse
}

MachineGetResponse contains the machine get result

type MachineIPMIGetResponse

type MachineIPMIGetResponse struct {
	Machine *models.V1MachineIPMIResponse
}

MachineIPMIGetResponse contains the machine ipmi get result

type MachineIPMIListResponse

type MachineIPMIListResponse struct {
	Machines []*models.V1MachineIPMIResponse
}

MachineIPMIListResponse contains the machine ipmi list result

type MachineListResponse

type MachineListResponse struct {
	Machines []*models.V1MachineResponse
}

MachineListResponse contains the machine list result

type MachinePowerResponse

type MachinePowerResponse struct {
	Machine *models.V1MachineResponse
}

MachinePowerResponse contains the machine power result

type MachineStateResponse

type MachineStateResponse struct {
	Machine *models.V1MachineResponse
}

MachineStateResponse contains the machine bios result

type NetworkAllocateRequest

type NetworkAllocateRequest struct {
	// a description for this entity
	Description string `json:"description,omitempty"`

	// the readable name
	Name string `json:"name,omitempty"`

	// the partition this network belongs to, TODO: can be empty ?
	// Required: true
	PartitionID string `json:"partitionid"`

	// the project this network belongs to, can be empty if globally available.
	// Required: true
	ProjectID string `json:"projectid,omitempty"`

	// A map of key/value pairs treated as labels.
	// Required: false
	Labels map[string]string `json:"labels"`
}

NetworkAllocateRequest is the request to allocate a new private network

type NetworkCreateRequest

type NetworkCreateRequest struct {
	ID *string `json:"id"`
	// a description for this entity
	Description string `json:"description,omitempty"`

	// the readable name
	Name string `json:"name,omitempty"`

	// if set to true, packets leaving this network get masqueraded behind interface ip.
	// Required: true
	Nat bool `json:"nat"`

	// the partition this network belongs to, TODO: can be empty ?
	// Required: true
	Partitionid string `json:"partitionid"`

	// the prefixes of this network, required.
	// Required: true
	Prefixes []string `json:"prefixes"`

	// the destination prefixes of this network
	// Required: true
	Destinationprefixes []string `json:"destinationprefixes"`

	// if set to true, this network acts a supernetwork for private networks
	// Required: true
	PrivateSuper bool `json:"privatesuper"`

	// the project this network belongs to, can be empty if globally available.
	// Required: true
	Projectid string `json:"projectid"`

	// if set to true, this network can be used for underlay communication
	// Required: true
	Underlay bool `json:"underlay"`

	// the vrf this network is associated with
	Vrf int64 `json:"vrf,omitempty"`

	// if set to true, the network can share the vrf with other networks
	// Required: false
	VrfShared bool `json:"vrfshared,omitempty"`
}

NetworkCreateRequest is the request for create a new network

type NetworkDetailResponse

type NetworkDetailResponse struct {
	Network *models.V1NetworkResponse
}

NetworkDetailResponse is the response of a NetworkList action

type NetworkFindRequest

type NetworkFindRequest struct {
	ID                  *string
	Name                *string
	PartitionID         *string
	ProjectID           *string
	Prefixes            []string
	DestinationPrefixes []string
	Nat                 *bool
	PrivateSuper        *bool
	Underlay            *bool
	Vrf                 *int64
	ParentNetworkID     *string
	Labels              map[string]string
}

NetworkFindRequest contains criteria for a network listing

type NetworkGetResponse

type NetworkGetResponse struct {
	Network *models.V1NetworkResponse
}

NetworkGetResponse contains the network get result

type NetworkListResponse

type NetworkListResponse struct {
	Networks []*models.V1NetworkResponse
}

NetworkListResponse is the response of a NetworkList action

type NetworkUpdateRequest

type NetworkUpdateRequest struct {
	// the network id for this update request.
	Networkid string `json:"networkid"`
	// Prefix the prefix to add/remove
	Prefix string
}

NetworkUpdateRequest is the request to update the Network

type PartitionCapacityResponse

type PartitionCapacityResponse struct {
	Capacity []*models.V1PartitionCapacity
}

PartitionCapacityResponse is the response of a PartitionGet action

type PartitionCreateRequest

type PartitionCreateRequest struct {
	ID                         string
	Name                       string
	Description                string
	Bootconfig                 BootConfig
	Mgmtserviceaddress         string
	Privatenetworkprefixlength int32
}

PartitionCreateRequest is the response of a ImageList action

type PartitionCreateResponse

type PartitionCreateResponse struct {
	Partition *models.V1PartitionResponse
}

PartitionCreateResponse is the response of a ImageList action

type PartitionGetResponse

type PartitionGetResponse struct {
	Partition *models.V1PartitionResponse
}

PartitionGetResponse is the response of a PartitionGet action

type PartitionListResponse

type PartitionListResponse struct {
	Partition []*models.V1PartitionResponse
}

PartitionListResponse is the response of a PartitionList action

type ProjectFindRequest

type ProjectFindRequest struct {
	ID     string
	Name   string
	Tenant string
}

ProjectFindRequest is the find request struct

type ProjectGetResponse

type ProjectGetResponse struct {
	Project *models.V1ProjectResponse
}

ProjectGetResponse is the response of a ProjectGet action

type ProjectListResponse

type ProjectListResponse struct {
	Project []*models.V1ProjectResponse
}

ProjectListResponse is the response of a ProjectList action

type SizeCreateRequest

type SizeCreateRequest struct {
	ID          string
	Name        string
	Description string
	Constraints []*models.V1SizeConstraint
}

SizeCreateRequest is the request to create a new Size

type SizeCreateResponse

type SizeCreateResponse struct {
	Size *models.V1SizeResponse
}

SizeCreateResponse is the response of a SizeList action

type SizeGetResponse

type SizeGetResponse struct {
	Size *models.V1SizeResponse
}

SizeGetResponse is the response of a SizeGet action

type SizeListResponse

type SizeListResponse struct {
	Size []*models.V1SizeResponse
}

SizeListResponse is the response of a SizeList action

type SizeTryResponse

type SizeTryResponse struct {
	Logs []*models.V1SizeMatchingLog
}

SizeTryResponse is the response of a SizeTry action

type SwitchListResponse

type SwitchListResponse struct {
	Switch []*models.V1SwitchResponse
}

SwitchListResponse is the response of a SwitchList action

Jump to

Keyboard shortcuts

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