Documentation ¶
Index ¶
- type BootConfig
- type BootDataDatabase
- func (bddb BootDataDatabase) Add(bp bssTypes.BootParams) (result map[string]string, err error)
- func (bddb BootDataDatabase) CheckNodeExistence(macs, xnames []string, nids []int32) (existingNodes []Node, nonExistingMacs, nonExistingXnames []string, ...)
- func (bddb BootDataDatabase) Close() error
- func (bddb BootDataDatabase) CreateDB(name string) (err error)
- func (bddb BootDataDatabase) Delete(bp bssTypes.BootParams) (nodesDeleted, bcsDeleted []string, err error)
- func (bddb BootDataDatabase) GetBootConfigsAll() ([]BootGroup, []BootConfig, int, error)
- func (bddb BootDataDatabase) GetBootConfigsByItems(kernelUri, initrdUri, cmdline string) ([]BootGroup, []BootConfig, int, error)
- func (bddb BootDataDatabase) GetBootParamsAll() ([]bssTypes.BootParams, error)
- func (bddb BootDataDatabase) GetBootParamsByMac(macs []string) ([]bssTypes.BootParams, error)
- func (bddb BootDataDatabase) GetBootParamsByName(names []string) ([]bssTypes.BootParams, error)
- func (bddb BootDataDatabase) GetBootParamsByNid(nids []int32) ([]bssTypes.BootParams, error)
- func (bddb BootDataDatabase) GetNodes() ([]Node, error)
- func (bddb BootDataDatabase) GetNodesByBootGroupId(bgId string) ([]Node, error)
- func (bddb BootDataDatabase) GetNodesByItems(macs, xnames []string, nids []int32) ([]Node, error)
- func (bddb BootDataDatabase) Update(bp bssTypes.BootParams) (nodesUpdated []string, err error)
- type BootGroup
- type BootGroupAssignment
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootConfig ¶
type BootConfig struct { Id string `json:"id"` // UUID of this boot configuration KernelUri string `json:"kernel_uri"` // URI to kernel image InitrdUri string `json:"initrd_uri,omitempty"` // URI to initrd image Cmdline string `json:"cmdline,omitempty"` // boot parameters associated with this image }
func NewBootConfig ¶
func NewBootConfig(kernelUri, initrdUri, cmdline string) (bc BootConfig, err error)
NewBootConfig creates a new BootConfig and populates it with kernel and initrd images, as well as additional boot parameters, generates a unique ID, and returns the new BootConfig. If kernelUri is blank, an error is returned.
type BootDataDatabase ¶
func Connect ¶
func Connect(host string, port uint, dbName, user, password string, ssl bool, extraDbOpts string) (BootDataDatabase, error)
Connect opens a new connections to a Postgres database and ensures it is reachable. If not, an error is thrown.
func (BootDataDatabase) Add ¶
func (bddb BootDataDatabase) Add(bp bssTypes.BootParams) (result map[string]string, err error)
Add takes a bssTypes.BootParams and adds nodes and their boot configuration to the database. If a node or its configuration already exists, it is ignored. If one or more nodes are specified and a configuration exists that does not belong to an existing node group, that config is used for that/those node(s). One or more nodes can be specified by _either_ their XNames, boot MAC addresses, or NIDs. One or more node group names can be specified instead of XNames, but this is currently not supported by Add.
func (BootDataDatabase) CheckNodeExistence ¶ added in v1.27.1
func (bddb BootDataDatabase) CheckNodeExistence(macs, xnames []string, nids []int32) (existingNodes []Node, nonExistingMacs, nonExistingXnames []string, nonExistingNids []int32, err error)
CheckNodeExistence takes takes a slice of MAC addresses, a slice of XNames, and a slice of NIDs and checks to see if the nodes corresponding to them exist in the nodes table. Those that do exist are added to an existing Node slice. MAC addresses, XNames, and NIDs that do not correspond to any existing nodes are added to a corresponding slice of non-existing MACs/XNames/NIDs. The slices of existing nodes, nonexisting MAC addresses, nonexisting XNames, and nonexisting NIDs are returned. If an error occurs when querying the database, it is returned.
func (BootDataDatabase) Close ¶
func (bddb BootDataDatabase) Close() error
Close calls the Close() method on the database object within the BootDataDatabase. If it errs, an error is returned.
func (BootDataDatabase) CreateDB ¶
func (bddb BootDataDatabase) CreateDB(name string) (err error)
CreateDB executes an SQL query to create the BSS database with the specified name (if it doesn't already exist) and creates the tables needed by BSS if they do not exist. If this query fails, an error is returned.
func (BootDataDatabase) Delete ¶
func (bddb BootDataDatabase) Delete(bp bssTypes.BootParams) (nodesDeleted, bcsDeleted []string, err error)
Delete removes one or more nodes (and the corresponding BootGroupAssignment(s)) from the database, as well as the corresponding BootGroup/BootConfig if no other node uses the same boot config. If kernel URI, initrd URI, and params are specified, Delete will also remove any boot config (and matching boot group) matching them. A list of node IDs and a map of boot group IDs to boot config IDs that were deleted are returned. If an error occurs with the deletion, it is returned.
func (BootDataDatabase) GetBootConfigsAll ¶
func (bddb BootDataDatabase) GetBootConfigsAll() ([]BootGroup, []BootConfig, int, error)
GetBootConfigsAll returns a slice of all BootGroups and a slice of all BootConfigs in the database, as well as the number of items in these slices (each BootGroup corresponds to a BootConfig, so these slices have the same number of items). If an error occurs with the query or scanning of the query results, an error is returned.
func (BootDataDatabase) GetBootConfigsByItems ¶
func (bddb BootDataDatabase) GetBootConfigsByItems(kernelUri, initrdUri, cmdline string) ([]BootGroup, []BootConfig, int, error)
GetBootConfigsByItems returns a slice of BootGroups and a slice of BootConfigs that match the passed kernel URI, initrd URI, and parameters, as well as the number of results that were returned (each BootGroup corresponds to a BootConfig, so these slices have the same number of items). If an error occurs with the query or scanning of the query results, an error is returned.
func (BootDataDatabase) GetBootParamsAll ¶
func (bddb BootDataDatabase) GetBootParamsAll() ([]bssTypes.BootParams, error)
GetBootParamsAll returns a slice of bssTypes.BootParams that contains all of the boot configurations for all nodes in the database. Each item contains node information (boot MAC address (if present), XName (if present), NID (if present)) as well as its associated boot configuration (kernel URI, initrd URI (if present), and parameters). If an error occurred while fetching the information, an error is returned.
func (BootDataDatabase) GetBootParamsByMac ¶
func (bddb BootDataDatabase) GetBootParamsByMac(macs []string) ([]bssTypes.BootParams, error)
GetBootParamsByMac returns a slice of bssTypes.BootParams that contains the boot configurations for nodes whose boot MAC addresses are found in the passed slice of MAC addresses. Each item contains node information (boot MAC address (if present), XName (if present), NID (if present)) as well as its associated boot configuration (kernel URI, initrd URI (if present), and parameters). If an error occurred while fetching the information, an error is returned.
func (BootDataDatabase) GetBootParamsByName ¶
func (bddb BootDataDatabase) GetBootParamsByName(names []string) ([]bssTypes.BootParams, error)
GetBootParamsByName returns a slice of bssTypes.BootParams that contains the boot configurations for nodes whose XNames are found in the passed slice of names. Each item contains node information (boot MAC address (if present), XName (if present), NID (if present)) as well as its associated boot configuration (kernel URI, initrd URI (if present), and parameters). If an error occurred while fetching the information, an error is returned.
func (BootDataDatabase) GetBootParamsByNid ¶
func (bddb BootDataDatabase) GetBootParamsByNid(nids []int32) ([]bssTypes.BootParams, error)
GetBootParamsByNid returns a slice of bssTypes.BootParams that contains the boot configurations for nodes whose NIDs are found in the passed slice of NIDs. Each item contains node information (boot MAC address (if present), XName (if present), NID (if present)) as well as its associated boot configuration (kernel URI, initrd URI (if present), and parameters). If an error occurred while fetching the information, an error is returned.
func (BootDataDatabase) GetNodes ¶
func (bddb BootDataDatabase) GetNodes() ([]Node, error)
GetNodes returns a list of all nodes in the nodes table within bddb.
func (BootDataDatabase) GetNodesByBootGroupId ¶
func (bddb BootDataDatabase) GetNodesByBootGroupId(bgId string) ([]Node, error)
GetNodesByBootGroupId returns a slice of Nodes that are a member of the BootGroup with an ID of bgId. If an error occurs during the query or scanning, an error is returned.
func (BootDataDatabase) GetNodesByItems ¶
func (bddb BootDataDatabase) GetNodesByItems(macs, xnames []string, nids []int32) ([]Node, error)
GetNodesByItems queries the nodes table for any Nodes that has an XName, MAC address, or NID that matches any in macs, xnames, or nids. Any matches found are returned. Otherwise, an empty Node list is returned. If no macs, xnames, or nids are specified, all nodes are returned.
func (BootDataDatabase) Update ¶
func (bddb BootDataDatabase) Update(bp bssTypes.BootParams) (nodesUpdated []string, err error)
Update modifies the boot parameters (and, optionally, the kernel and/or initramfs URI) of one or more existing nodes, specified by node ID, XName, or MAC address. If any of the passed nodes does not exist in the database, the operation aborts and an error is returned. A slice of strings is returned containing the node IDs of nodes whose values were updated.
type BootGroup ¶
type BootGroup struct { Id string `json:"id"` BootConfigId string `json:"boot_config_id"` Name string `json:"name"` Description string `json:"description"` }
func NewBootGroup ¶
NewBootGroup creates a new BootGroup and populates it with the specified boot config ID, name, and description, as well as populates its ID with a unique identifier. The new BootGroup is returned.
type BootGroupAssignment ¶
type BootGroupAssignment struct { BootGroupId string `json:"boot_group_id"` NodeId string `json:"node_id"` }
func NewBootGroupAssignment ¶
func NewBootGroupAssignment(bgId, nodeId string) (bga BootGroupAssignment, err error)
NewBootGroupAssignment creates a new BootGroupAssignment and populates it with the boot group id and node ID specified, returning the BootGroupAssignment that got created. If either bgId or nodeId is blank, an error is returned.