Documentation ¶
Overview ¶
Package model provides the data model for grendel
Index ¶
- Constants
- Variables
- func NewBootToken(id, mac string) (string, error)
- func NewFirmwareToken(mac string, fwtype firmware.Build) (string, error)
- func ParseFirmwareToken(token string) (firmware.Build, error)
- type BootClaims
- type BootImage
- type BootImageList
- type BuntStore
- func (s *BuntStore) BootImages() (BootImageList, error)
- func (s *BuntStore) Close() error
- func (s *BuntStore) FindHosts(ns *nodeset.NodeSet) (HostList, error)
- func (s *BuntStore) Hosts() (HostList, error)
- func (s *BuntStore) LoadBootImage(name string) (*BootImage, error)
- func (s *BuntStore) LoadHostFromID(id string) (*Host, error)
- func (s *BuntStore) LoadHostFromMAC(mac string) (*Host, error)
- func (s *BuntStore) LoadHostFromName(name string) (*Host, error)
- func (s *BuntStore) ProvisionHosts(ns *nodeset.NodeSet, provision bool) error
- func (s *BuntStore) ResolveIPv4(fqdn string) ([]net.IP, error)
- func (s *BuntStore) ReverseResolve(ip string) ([]string, error)
- func (s *BuntStore) SetBootImage(ns *nodeset.NodeSet, name string) error
- func (s *BuntStore) StoreBootImage(image *BootImage) error
- func (s *BuntStore) StoreBootImages(images BootImageList) error
- func (s *BuntStore) StoreHost(host *Host) error
- func (s *BuntStore) StoreHosts(hosts HostList) error
- type DataStore
- type Host
- type HostList
- type HostMap
- type NetInterface
Constants ¶
const ( HostKeyPrefix = "host" BootImageKeyPrefix = "image" )
Variables ¶
var ( // ErrNotFound is returned when a model is not found in the store ErrNotFound = errors.New("not found") // ErrInvalidData is returned when a model is is missing required data ErrInvalidData = errors.New("invalid data") )
Functions ¶
func NewBootToken ¶
Types ¶
type BootClaims ¶
func ParseBootToken ¶ added in v0.0.2
func ParseBootToken(token string) (*BootClaims, error)
type BootImage ¶
type BootImage struct { ID ksuid.KSUID `json:"id"` Name string `json:"name" validate:"required"` KernelPath string `json:"kernel" validate:"required"` InitrdPaths []string `json:"initrd"` LiveImage string `json:"liveimg"` CommandLine string `json:"cmdline"` Verify bool `json:"verify"` }
func (*BootImage) CheckPathsExist ¶
type BootImageList ¶
type BootImageList []*BootImage
func NewBootImageList ¶
func NewBootImageList() BootImageList
type BuntStore ¶
type BuntStore struct {
// contains filtered or unexported fields
}
BuntStore implements a Grendel Datastore using BuntDB
func NewBuntStore ¶
NewBuntStore returns a new BuntStore using the given database filename. For memory only you can provide `:memory:`
func (*BuntStore) BootImages ¶
func (s *BuntStore) BootImages() (BootImageList, error)
BootImages returns a list of all boot images
func (*BuntStore) LoadBootImage ¶
LoadBootImage returns a BootImage with the given name
func (*BuntStore) LoadHostFromID ¶
LoadHostFromID returns the Host with the given ID
func (*BuntStore) LoadHostFromMAC ¶
LoadHostFromMAC returns the Host that has a network interface with the give MAC address
func (*BuntStore) LoadHostFromName ¶
LoadHostFromName returns the Host with the given name
func (*BuntStore) ProvisionHosts ¶
ProvisionHosts sets all hosts in the given NodeSet to provision (true) or unprovision (false)
func (*BuntStore) ResolveIPv4 ¶
ResolveIPv4 returns the list of IPv4 addresses with the given FQDN
func (*BuntStore) ReverseResolve ¶
ReverseResolve returns the list of FQDNs for the given IP
func (*BuntStore) SetBootImage ¶
SetBootImage sets all hosts to use the BootImage with the given name
func (*BuntStore) StoreBootImage ¶
StoreBootImage stores a boot image in the data store. If the boot image exists it is overwritten
func (*BuntStore) StoreBootImages ¶
func (s *BuntStore) StoreBootImages(images BootImageList) error
StoreBootImages stores a list of boot images in the data store. If the boot image exists it is overwritten
func (*BuntStore) StoreHost ¶
StoreHost stores a host in the data store. If the host exists it is overwritten
func (*BuntStore) StoreHosts ¶
StoreHosts stores a list of host in the data store. If the host exists it is overwritten
type DataStore ¶
type DataStore interface { // BootImages returns a list of all boot images BootImages() (BootImageList, error) // LoadBootImage returns a BootImage with the given name LoadBootImage(name string) (*BootImage, error) // StoreBootImage stores the BootImage in the data store StoreBootImage(image *BootImage) error // StoreBootImages stores a list of BootImages in the data store StoreBootImages(images BootImageList) error // SetBootImage sets all hosts to use the BootImage with the given name SetBootImage(ns *nodeset.NodeSet, name string) error // Hosts returns a list of all the hosts Hosts() (HostList, error) // FindHosts returns a list of all the hosts in the given NodeSet FindHosts(ns *nodeset.NodeSet) (HostList, error) // ProvisionHosts sets all hosts in the given NodeSet to provision (true) or unprovision (false) ProvisionHosts(ns *nodeset.NodeSet, provision bool) error // StoreHosts stores a hosts in the data store. If the host exists it is overwritten StoreHost(host *Host) error // StoreHosts stores a list of hosts in the data store. If the host exists it is overwritten StoreHosts(hosts HostList) error // LoadHostFromID returns the Host with the given ID LoadHostFromID(id string) (*Host, error) // LoadHostFromName returns the Host with the given name LoadHostFromName(name string) (*Host, error) // LoadHostFromMAC returns the Host that has a network interface with the give MAC address LoadHostFromMAC(mac string) (*Host, error) // ResolveIPv4 returns the list of IPv4 addresses with the given FQDN ResolveIPv4(fqdn string) ([]net.IP, error) // ReverseResolve returns the list of FQDNs for the given IP ReverseResolve(ip string) ([]string, error) // Close data store Close() error }
DataStore
func NewDataStore ¶
type Host ¶
type Host struct { ID ksuid.KSUID `json:"id,omitempty"` Name string `json:"name" validate:"required,hostname"` Interfaces []*NetInterface `json:"interfaces"` Provision bool `json:"provision"` Firmware firmware.Build `json:"firmware"` BootImage string `json:"boot_image"` }
func (*Host) Interface ¶
func (h *Host) Interface(mac net.HardwareAddr) *NetInterface
func (*Host) InterfaceBMC ¶
func (h *Host) InterfaceBMC() *NetInterface
func (*Host) MarshalJSON ¶
func (*Host) UnmarshalJSON ¶
type HostList ¶
type HostList []*Host
func NewHostList ¶
func NewHostList() HostList
func (HostList) FilterPrefix ¶
type HostMap ¶
func NewHostMap ¶
func NewHostMap() *HostMap
type NetInterface ¶
type NetInterface struct { MAC net.HardwareAddr `json:"mac" validate:"required"` Name string `json:"ifname"` IP net.IP `json:"ip"` FQDN string `json:"fqdn"` BMC bool `json:"bmc"` }
func (*NetInterface) MarshalJSON ¶
func (n *NetInterface) MarshalJSON() ([]byte, error)
func (*NetInterface) UnmarshalJSON ¶
func (n *NetInterface) UnmarshalJSON(data []byte) error