Documentation
¶
Index ¶
- Variables
- type IPSearchQuery
- type Integerinfo
- type MachineSearchQuery
- type NetworkSearchQuery
- type RethinkStore
- func (rs *RethinkStore) AcquireRandomUniqueInteger() (uint, error)
- func (rs *RethinkStore) AcquireUniqueInteger(value uint) (uint, error)
- func (rs *RethinkStore) Close() error
- func (rs *RethinkStore) Connect() error
- func (rs *RethinkStore) CreateIP(ip *metal.IP) error
- func (rs *RethinkStore) CreateImage(i *metal.Image) error
- func (rs *RethinkStore) CreateMachine(m *metal.Machine) error
- func (rs *RethinkStore) CreateNetwork(nw *metal.Network) error
- func (rs *RethinkStore) CreatePartition(p *metal.Partition) error
- func (rs *RethinkStore) CreateProvisioningEventContainer(ec *metal.ProvisioningEventContainer) error
- func (rs *RethinkStore) CreateSize(size *metal.Size) error
- func (rs *RethinkStore) CreateSwitch(s *metal.Switch) error
- func (rs *RethinkStore) DeleteIP(ip *metal.IP) error
- func (rs *RethinkStore) DeleteImage(i *metal.Image) error
- func (rs *RethinkStore) DeleteMachine(m *metal.Machine) error
- func (rs *RethinkStore) DeleteNetwork(nw *metal.Network) error
- func (rs *RethinkStore) DeletePartition(p *metal.Partition) error
- func (rs *RethinkStore) DeleteSize(size *metal.Size) error
- func (rs *RethinkStore) DeleteSwitch(s *metal.Switch) error
- func (rs *RethinkStore) FindAvailableMachine(partitionid, sizeid string) (*metal.Machine, error)
- func (rs *RethinkStore) FindIPByID(id string) (*metal.IP, error)
- func (rs *RethinkStore) FindIPs(q *IPSearchQuery, ip *metal.IP) error
- func (rs *RethinkStore) FindImage(id string) (*metal.Image, error)
- func (rs *RethinkStore) FindMachine(q *MachineSearchQuery, ms *metal.Machine) error
- func (rs *RethinkStore) FindMachineByID(id string) (*metal.Machine, error)
- func (rs *RethinkStore) FindNetwork(q *NetworkSearchQuery, n *metal.Network) error
- func (rs *RethinkStore) FindNetworkByID(id string) (*metal.Network, error)
- func (rs *RethinkStore) FindPartition(id string) (*metal.Partition, error)
- func (rs *RethinkStore) FindProvisioningEventContainer(id string) (*metal.ProvisioningEventContainer, error)
- func (rs *RethinkStore) FindSize(id string) (*metal.Size, error)
- func (rs *RethinkStore) FindSwitch(id string) (*metal.Switch, error)
- func (rs *RethinkStore) FromHardware(hw metal.MachineHardware) (*metal.Size, []*metal.SizeMatchingLog, error)
- func (rs *RethinkStore) Health() error
- func (rs *RethinkStore) InsertWaitingMachine(m *metal.Machine) error
- func (rs *RethinkStore) ListIPs() (metal.IPs, error)
- func (rs *RethinkStore) ListImages() (metal.Images, error)
- func (rs *RethinkStore) ListMachines() (metal.Machines, error)
- func (rs *RethinkStore) ListNetworks() (metal.Networks, error)
- func (rs *RethinkStore) ListPartitions() (metal.Partitions, error)
- func (rs *RethinkStore) ListProvisioningEventContainers() (metal.ProvisioningEventContainers, error)
- func (rs *RethinkStore) ListSizes() (metal.Sizes, error)
- func (rs *RethinkStore) ListSwitches() ([]metal.Switch, error)
- func (rs *RethinkStore) Mock() *r.Mock
- func (rs *RethinkStore) ReleaseUniqueInteger(id uint) error
- func (rs *RethinkStore) RemoveWaitingMachine(m *metal.Machine) error
- func (rs *RethinkStore) SearchIPs(q *IPSearchQuery, ips *metal.IPs) error
- func (rs *RethinkStore) SearchMachines(q *MachineSearchQuery, ms *metal.Machines) error
- func (rs *RethinkStore) SearchNetworks(q *NetworkSearchQuery, ns *metal.Networks) error
- func (rs *RethinkStore) SearchSwitches(rackid string, macs []string) ([]metal.Switch, error)
- func (rs *RethinkStore) SearchSwitchesConnectedToMachine(m *metal.Machine) ([]metal.Switch, error)
- func (rs *RethinkStore) UpdateIP(oldIP *metal.IP, newIP *metal.IP) error
- func (rs *RethinkStore) UpdateImage(oldImage *metal.Image, newImage *metal.Image) error
- func (rs *RethinkStore) UpdateMachine(oldMachine *metal.Machine, newMachine *metal.Machine) error
- func (rs *RethinkStore) UpdateNetwork(oldNetwork *metal.Network, newNetwork *metal.Network) error
- func (rs *RethinkStore) UpdatePartition(oldPartition *metal.Partition, newPartition *metal.Partition) error
- func (rs *RethinkStore) UpdateProvisioningEventContainer(old *metal.ProvisioningEventContainer, new *metal.ProvisioningEventContainer) error
- func (rs *RethinkStore) UpdateSize(oldSize *metal.Size, newSize *metal.Size) error
- func (rs *RethinkStore) UpdateSwitch(oldSwitch *metal.Switch, newSwitch *metal.Switch) error
- func (rs *RethinkStore) UpdateWaitingMachine(m *metal.Machine) error
- func (rs *RethinkStore) UpsertProvisioningEventContainer(ec *metal.ProvisioningEventContainer) error
- func (rs *RethinkStore) WaitForMachineAllocation(ctx context.Context, m *metal.Machine) (*metal.Machine, error)
Constants ¶
This section is empty.
Variables ¶
var ( // IntegerPoolRangeMin the minimum integer to get from the pool IntegerPoolRangeMin = uint(1) // IntegerPoolRangeMax the maximum integer to get from the pool IntegerPoolRangeMax = uint(131072) )
Functions ¶
This section is empty.
Types ¶
type IPSearchQuery ¶
type IPSearchQuery struct {
IPAddress *string `` /* 135-byte string literal not displayed */
ParentPrefixCidr *string `json:"networkprefix" description:"the prefix of the network this ip address belongs to"`
NetworkID *string `json:"networkid" description:"the network this ip allocate request address belongs to"`
Tags []string `json:"tags" description:"the tags that are assigned to this ip address"`
ProjectID *string `json:"projectid" description:"the project this ip address belongs to, empty if not strong coupled"`
Type *string `json:"type" description:"the type of the ip address, ephemeral or static"`
MachineID *string `json:"machineid" description:"the machine an ip address is associated to"`
}
IPSearchQuery can be used to search networks.
type Integerinfo ¶
type Integerinfo struct {
IsInitialized bool `rethinkdb:"isInitialized" json:"isInitialized"`
}
Integerinfo contains information on the integer pool.
type MachineSearchQuery ¶
type MachineSearchQuery struct {
ID *string `json:"id"`
Name *string `json:"name"`
PartitionID *string `json:"partition_id"`
SizeID *string `json:"sizeid"`
RackID *string `json:"rackid"`
Liveliness *string `json:"liveliness"`
Tags []string `json:"tags"`
// allocation
AllocationName *string `json:"allocation_name"`
AllocationProject *string `json:"allocation_project"`
AllocationImageID *string `json:"allocation_image_id"`
AllocationHostname *string `json:"allocation_hostname"`
AllocationSucceeded *bool `json:"allocation_succeeded"`
// network
NetworkIDs []string `json:"network_ids"`
NetworkPrefixes []string `json:"network_prefixes"`
NetworkIPs []string `json:"network_ips"`
NetworkDestinationPrefixes []string `json:"network_destination_prefixes"`
NetworkVrfs []int64 `json:"network_vrfs"`
NetworkPrivate *bool `json:"network_private"`
NetworkASNs []int64 `json:"network_asns"`
NetworkNat *bool `json:"network_nat"`
NetworkUnderlay *bool `json:"network_underlay"`
// hardware
HardwareMemory *int64 `json:"hardware_memory"`
HardwareCPUCores *int64 `json:"hardware_cpu_cores"`
// nics
NicsMacAddresses []string `json:"nics_mac_addresses"`
NicsNames []string `json:"nics_names"`
NicsVrfs []string `json:"nics_vrfs"`
NicsNeighborMacAddresses []string `json:"nics_neighbor_mac_addresses"`
NicsNeighborNames []string `json:"nics_neighbor_names"`
NicsNeighborVrfs []string `json:"nics_neighbor_vrfs"`
// disks
DiskNames []string `json:"disk_names"`
DiskSizes []int64 `json:"disk_sizes"`
// state
StateValue *string `json:"state_value"`
// ipmi
IpmiAddress *string `json:"ipmi_address"`
IpmiMacAddress *string `json:"ipmi_mac_address"`
IpmiUser *string `json:"ipmi_user"`
IpmiInterface *string `json:"ipmi_interface"`
// fru
FruChassisPartNumber *string `json:"fru_chassis_part_number"`
FruChassisPartSerial *string `json:"fru_chassis_part_serial"`
FruBoardMfg *string `json:"fru_board_mfg"`
FruBoardMfgSerial *string `json:"fru_board_mfg_serial"`
FruBoardPartNumber *string `json:"fru_board_part_number"`
FruProductManufacturer *string `json:"fru_product_manufacturer"`
FruProductPartNumber *string `json:"fru_product_part_number"`
FruProductSerial *string `json:"fru_product_serial"`
}
MachineSearchQuery can be used to search machines.
type NetworkSearchQuery ¶
type NetworkSearchQuery struct {
ID *string `json:"id"`
Name *string `json:"name"`
PartitionID *string `json:"partitionid"`
ProjectID *string `json:"projectid"`
Prefixes []string `json:"prefixes"`
DestinationPrefixes []string `json:"destinationprefixes"`
Nat *bool `json:"nat"`
PrivateSuper *bool `json:"privatesuper"`
Underlay *bool `json:"underlay"`
Vrf *int64 `json:"vrf"`
ParentNetworkID *string `json:"parentnetworkid"`
Labels map[string]string `json:"labels"`
}
NetworkSearchQuery can be used to search networks.
type RethinkStore ¶
type RethinkStore struct {
*zap.SugaredLogger
// contains filtered or unexported fields
}
A RethinkStore is the database access layer for rethinkdb.
func InitMockDB ¶
func InitMockDB() (*RethinkStore, *r.Mock)
InitMockDB ...
Description: This Function initializes the Mocked rethink DB. It is recommended to execute metal.InitMockDBData() to fill it with mocks
Return Values: - RethinkStore // The Database - Mock // The Mock endpoint (Used for mocks)
func InitTestDB ¶
func InitTestDB(t *testing.T) (*RethinkStore, testcontainers.Container, context.Context)
InitTestDB create a docker container whith rethinkdb for real integration tests.
func (*RethinkStore) AcquireRandomUniqueInteger ¶
func (rs *RethinkStore) AcquireRandomUniqueInteger() (uint, error)
AcquireRandomUniqueInteger returns a random unique integer from the pool.
func (*RethinkStore) AcquireUniqueInteger ¶
func (rs *RethinkStore) AcquireUniqueInteger(value uint) (uint, error)
AcquireUniqueInteger returns a unique integer from the pool.
func (*RethinkStore) Close ¶
func (rs *RethinkStore) Close() error
Close closes the database session.
func (*RethinkStore) Connect ¶
func (rs *RethinkStore) Connect() error
Connect connects to the database. If there is an error, it will run until there is a connection.
func (*RethinkStore) CreateIP ¶
func (rs *RethinkStore) CreateIP(ip *metal.IP) error
CreateIP creates a new ip.
func (*RethinkStore) CreateImage ¶
func (rs *RethinkStore) CreateImage(i *metal.Image) error
CreateImage creates a new image.
func (*RethinkStore) CreateMachine ¶
func (rs *RethinkStore) CreateMachine(m *metal.Machine) error
CreateMachine creates a new machine in the database as "unallocated new machines". If the given machine has an allocation, the function returns an error because allocated machines cannot be created. If there is already a machine with the given ID in the database it will be replaced the the given machine. CreateNetwork creates a new network.
func (*RethinkStore) CreateNetwork ¶
func (rs *RethinkStore) CreateNetwork(nw *metal.Network) error
CreateNetwork creates a new network.
func (*RethinkStore) CreatePartition ¶
func (rs *RethinkStore) CreatePartition(p *metal.Partition) error
CreatePartition creates a new partition.
func (*RethinkStore) CreateProvisioningEventContainer ¶
func (rs *RethinkStore) CreateProvisioningEventContainer(ec *metal.ProvisioningEventContainer) error
CreateProvisioningEventContainer creates a new provisioning event container.
func (*RethinkStore) CreateSize ¶
func (rs *RethinkStore) CreateSize(size *metal.Size) error
CreateSize creates a new size.
func (*RethinkStore) CreateSwitch ¶
func (rs *RethinkStore) CreateSwitch(s *metal.Switch) error
CreateSwitch creates a new switch.
func (*RethinkStore) DeleteIP ¶
func (rs *RethinkStore) DeleteIP(ip *metal.IP) error
DeleteIP deletes an ip.
func (*RethinkStore) DeleteImage ¶
func (rs *RethinkStore) DeleteImage(i *metal.Image) error
DeleteImage deletes an image.
func (*RethinkStore) DeleteMachine ¶
func (rs *RethinkStore) DeleteMachine(m *metal.Machine) error
DeleteMachine removes a machine from the database.
func (*RethinkStore) DeleteNetwork ¶
func (rs *RethinkStore) DeleteNetwork(nw *metal.Network) error
DeleteNetwork deletes an network.
func (*RethinkStore) DeletePartition ¶
func (rs *RethinkStore) DeletePartition(p *metal.Partition) error
DeletePartition delets a partition.
func (*RethinkStore) DeleteSize ¶
func (rs *RethinkStore) DeleteSize(size *metal.Size) error
DeleteSize deletes a size.
func (*RethinkStore) DeleteSwitch ¶
func (rs *RethinkStore) DeleteSwitch(s *metal.Switch) error
DeleteSwitch deletes a switch.
func (*RethinkStore) FindAvailableMachine ¶
func (rs *RethinkStore) FindAvailableMachine(partitionid, sizeid string) (*metal.Machine, error)
FindAvailableMachine returns an available machine that momentarily also sits in the wait table.
func (*RethinkStore) FindIPByID ¶
func (rs *RethinkStore) FindIPByID(id string) (*metal.IP, error)
FindIPByID returns an ip of a given id.
func (*RethinkStore) FindIPs ¶
func (rs *RethinkStore) FindIPs(q *IPSearchQuery, ip *metal.IP) error
FindIPs returns an IP by the given query, fails if there is no record or multiple records found.
func (*RethinkStore) FindImage ¶
func (rs *RethinkStore) FindImage(id string) (*metal.Image, error)
FindImage returns an image or a given id.
func (*RethinkStore) FindMachine ¶
func (rs *RethinkStore) FindMachine(q *MachineSearchQuery, ms *metal.Machine) error
FindMachine returns a machine by the given query, fails if there is no record or multiple records found.
func (*RethinkStore) FindMachineByID ¶
func (rs *RethinkStore) FindMachineByID(id string) (*metal.Machine, error)
FindMachineByID returns a machine for a given id.
func (*RethinkStore) FindNetwork ¶
func (rs *RethinkStore) FindNetwork(q *NetworkSearchQuery, n *metal.Network) error
FindNetwork returns a machine by the given query, fails if there is no record or multiple records found.
func (*RethinkStore) FindNetworkByID ¶
func (rs *RethinkStore) FindNetworkByID(id string) (*metal.Network, error)
FindNetworkByID returns an network of a given id.
func (*RethinkStore) FindPartition ¶
func (rs *RethinkStore) FindPartition(id string) (*metal.Partition, error)
FindPartition return a partition for the given id.
func (*RethinkStore) FindProvisioningEventContainer ¶
func (rs *RethinkStore) FindProvisioningEventContainer(id string) (*metal.ProvisioningEventContainer, error)
FindProvisioningEventContainer finds a provisioning event container to a given machine id.
func (*RethinkStore) FindSize ¶
func (rs *RethinkStore) FindSize(id string) (*metal.Size, error)
FindSize return a size for a given id.
func (*RethinkStore) FindSwitch ¶
func (rs *RethinkStore) FindSwitch(id string) (*metal.Switch, error)
FindSwitch returns a switch for a given id.
func (*RethinkStore) FromHardware ¶
func (rs *RethinkStore) FromHardware(hw metal.MachineHardware) (*metal.Size, []*metal.SizeMatchingLog, error)
FromHardware tries to find a size which matches the given hardware specs.
func (*RethinkStore) Health ¶
func (rs *RethinkStore) Health() error
Health checks if the connection to the database is ok.
func (*RethinkStore) InsertWaitingMachine ¶
func (rs *RethinkStore) InsertWaitingMachine(m *metal.Machine) error
InsertWaitingMachine adds a machine to the wait table.
func (*RethinkStore) ListIPs ¶
func (rs *RethinkStore) ListIPs() (metal.IPs, error)
ListIPs returns all ips.
func (*RethinkStore) ListImages ¶
func (rs *RethinkStore) ListImages() (metal.Images, error)
ListImages returns all images.
func (*RethinkStore) ListMachines ¶
func (rs *RethinkStore) ListMachines() (metal.Machines, error)
ListMachines returns all machines.
func (*RethinkStore) ListNetworks ¶
func (rs *RethinkStore) ListNetworks() (metal.Networks, error)
ListNetworks returns all networks.
func (*RethinkStore) ListPartitions ¶
func (rs *RethinkStore) ListPartitions() (metal.Partitions, error)
ListPartitions returns all partition.
func (*RethinkStore) ListProvisioningEventContainers ¶
func (rs *RethinkStore) ListProvisioningEventContainers() (metal.ProvisioningEventContainers, error)
ListProvisioningEventContainers returns all machine provisioning event containers.
func (*RethinkStore) ListSizes ¶
func (rs *RethinkStore) ListSizes() (metal.Sizes, error)
ListSizes returns all sizes.
func (*RethinkStore) ListSwitches ¶
func (rs *RethinkStore) ListSwitches() ([]metal.Switch, error)
ListSwitches returns all known switches.
func (*RethinkStore) Mock ¶
func (rs *RethinkStore) Mock() *r.Mock
Mock return the mock from the rethinkdb driver and sets the session to this mock. This MUST NOT be called in productive code.
func (*RethinkStore) ReleaseUniqueInteger ¶
func (rs *RethinkStore) ReleaseUniqueInteger(id uint) error
ReleaseUniqueInteger returns a unique integer to the pool.
func (*RethinkStore) RemoveWaitingMachine ¶
func (rs *RethinkStore) RemoveWaitingMachine(m *metal.Machine) error
RemoveWaitingMachine removes a machine from the wait table.
func (*RethinkStore) SearchIPs ¶
func (rs *RethinkStore) SearchIPs(q *IPSearchQuery, ips *metal.IPs) error
SearchIPs returns the result of the ips search request query.
func (*RethinkStore) SearchMachines ¶
func (rs *RethinkStore) SearchMachines(q *MachineSearchQuery, ms *metal.Machines) error
SearchMachines returns the result of the machines search request query.
func (*RethinkStore) SearchNetworks ¶
func (rs *RethinkStore) SearchNetworks(q *NetworkSearchQuery, ns *metal.Networks) error
SearchNetworks returns the networks that match the given properties
func (*RethinkStore) SearchSwitches ¶
SearchSwitches searches for switches by the given parameters.
func (*RethinkStore) SearchSwitchesConnectedToMachine ¶
SearchSwitchesConnectedToMachine searches switches that are connected to the given machine.
func (*RethinkStore) UpdateImage ¶
UpdateImage updates an image.
func (*RethinkStore) UpdateMachine ¶
UpdateMachine replaces a machine in the database if the 'changed' field of the old value equals the 'changed' field of the recored in the database.
func (*RethinkStore) UpdateNetwork ¶
UpdateNetwork updates an network.
func (*RethinkStore) UpdatePartition ¶
func (rs *RethinkStore) UpdatePartition(oldPartition *metal.Partition, newPartition *metal.Partition) error
UpdatePartition updates a partition.
func (*RethinkStore) UpdateProvisioningEventContainer ¶
func (rs *RethinkStore) UpdateProvisioningEventContainer(old *metal.ProvisioningEventContainer, new *metal.ProvisioningEventContainer) error
UpdateProvisioningEventContainer updates a provisioning event container.
func (*RethinkStore) UpdateSize ¶
UpdateSize updates a size.
func (*RethinkStore) UpdateSwitch ¶
UpdateSwitch updates a switch.
func (*RethinkStore) UpdateWaitingMachine ¶
func (rs *RethinkStore) UpdateWaitingMachine(m *metal.Machine) error
UpdateWaitingMachine updates a machine in the wait table with the given machine
func (*RethinkStore) UpsertProvisioningEventContainer ¶
func (rs *RethinkStore) UpsertProvisioningEventContainer(ec *metal.ProvisioningEventContainer) error
UpsertProvisioningEventContainer inserts a machine's event container.
func (*RethinkStore) WaitForMachineAllocation ¶
func (rs *RethinkStore) WaitForMachineAllocation(ctx context.Context, m *metal.Machine) (*metal.Machine, error)
WaitForMachineAllocation listens on changes on the wait table for a given machine and returns the changed machine.