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 ParseConfigs() error
- func ParseFirmwareToken(token string) (firmware.Build, error)
- type Bond
- type BootClaims
- type BootImage
- type BootImageList
- type BuntStore
- func (s *BuntStore) BootImages() (BootImageList, error)
- func (s *BuntStore) Close() error
- func (s *BuntStore) DeleteBootImages(names []string) error
- func (s *BuntStore) DeleteHosts(ns *nodeset.NodeSet) error
- func (s *BuntStore) DeleteUser(username string) error
- func (s *BuntStore) FindHosts(ns *nodeset.NodeSet) (HostList, error)
- func (s *BuntStore) FindTags(tags []string) (*nodeset.NodeSet, error)
- func (s *BuntStore) GetUsers() ([]User, 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) MatchTags(tags []string) (*nodeset.NodeSet, 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
- func (s *BuntStore) StoreUser(username, password string) (string, error)
- func (s *BuntStore) TagHosts(ns *nodeset.NodeSet, tags []string) error
- func (s *BuntStore) UntagHosts(ns *nodeset.NodeSet, tags []string) error
- func (s *BuntStore) UpdateUser(username, role string) error
- func (s *BuntStore) VerifyUser(username, password string) (bool, string, error)
- type DataStore
- type Endpoints
- func (e *Endpoints) BaseURL() string
- func (e *Endpoints) BootFileURL() string
- func (e *Endpoints) CloudInitURL() string
- func (e *Endpoints) CompleteURL() string
- func (e *Endpoints) IgnitionURL() string
- func (e *Endpoints) InitrdURL(index int) string
- func (e *Endpoints) IpxeURL() string
- func (e *Endpoints) KernelURL() string
- func (e *Endpoints) KickstartURL() string
- func (e *Endpoints) KickstartURLParts() (string, string)
- func (e *Endpoints) LiveImageURL() string
- func (e *Endpoints) MetaDataURL() string
- func (e *Endpoints) ProvisionURL(name string) string
- func (e *Endpoints) ProxmoxURL() string
- func (e *Endpoints) RepoURL() string
- func (e *Endpoints) RootFSURL() string
- func (e *Endpoints) UserDataURL() string
- func (e *Endpoints) VendorDataURL() string
- type Host
- func (h *Host) BootInterface() *NetInterface
- func (h *Host) FromJSON(hostJSON string)
- func (h *Host) HasAnyTags(tags ...string) bool
- func (h *Host) HasTags(tags ...string) bool
- func (h *Host) HostType() string
- func (h *Host) Interface(mac net.HardwareAddr) *NetInterface
- func (h *Host) InterfaceBMC() *NetInterface
- func (h *Host) InterfaceBonded(peer string) bool
- func (h *Host) MarshalJSON() ([]byte, error)
- func (h *Host) ToJSON() string
- func (h *Host) UnmarshalJSON(data []byte) error
- type HostList
- type HostMap
- type NetInterface
- func (n *NetInterface) Addr() netip.Addr
- func (n *NetInterface) AddrString() string
- func (n *NetInterface) CIDR() string
- func (n *NetInterface) DNS() []net.IP
- func (n *NetInterface) DNSList() []string
- func (n *NetInterface) Domain() string
- func (n *NetInterface) DomainSearch() []string
- func (n *NetInterface) Gateway() netip.Addr
- func (n *NetInterface) HostName() string
- func (n *NetInterface) HostNameIndex(idx int) string
- func (n *NetInterface) InterfaceMTU() uint16
- func (n *NetInterface) MarshalJSON() ([]byte, error)
- func (n *NetInterface) Netmask() net.IPMask
- func (n *NetInterface) NetmaskString() string
- func (n *NetInterface) ShortName() string
- func (n *NetInterface) ToStdAddr() net.IP
- func (n *NetInterface) UnmarshalJSON(data []byte) error
- type Subnet
- type User
- type UserValue
Constants ¶
const ( HostKeyPrefix = "host" BootImageKeyPrefix = "image" UserKeyPrefix = "user" )
Variables ¶
var ( ProvisionAddr netip.AddrPort = netip.MustParseAddrPort("0.0.0.0:80") ProvisionScheme string = "http" ProvisionHostname string = "" Subnets []Subnet = []Subnet{} DefaultDNS []net.IP = []net.IP{} DefaultDomainSearch []string = []string{} DefaultMTU uint16 = 1500 DefaultGateway netip.Addr )
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") // ErrDuplicateEntry is returned when attempting to store a model with the same ID or Name ErrDuplicateEntry = errors.New("duplicate entry") )
Functions ¶
func NewBootToken ¶
func ParseConfigs ¶ added in v0.0.8
func ParseConfigs() error
Types ¶
type Bond ¶ added in v0.0.11
type Bond struct { NetInterface Peers []string `json:"peers"` }
func (*Bond) MarshalJSON ¶ added in v0.0.11
func (*Bond) UnmarshalJSON ¶ added in v0.0.11
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"` ProvisionTemplate string `json:"provision_template"` ProvisionTemplates map[string]string `json:"provision_templates"` UserData string `json:"user_data"` Butane string `json:"butane"` }
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) DeleteBootImages ¶ added in v0.0.6
DeleteBootImages deletes boot images from the data store.
func (*BuntStore) DeleteHosts ¶ added in v0.0.6
DeleteHosts deletes all hosts in the given nodeset.NodeSet from the data store.
func (*BuntStore) DeleteUser ¶ added in v0.0.9
DeleteUser deletes the given user
func (*BuntStore) FindTags ¶ added in v0.0.5
FindTags returns a nodeset.NodeSet of all the hosts with the given tags
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) MatchTags ¶ added in v0.0.9
MatchTags returns a nodeset.NodeSet of all the hosts with the all given tags
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
func (*BuntStore) UntagHosts ¶ added in v0.0.5
UntagHosts removes tags from all hosts in the given NodeSet
func (*BuntStore) UpdateUser ¶ added in v0.0.9
UpdateUser updates the role of the given users
type DataStore ¶
type DataStore interface { // StoreUser stores the User in the data store StoreUser(username, password string) (string, error) // VerifyUser checks if the given username exists in the data store VerifyUser(username, password string) (bool, string, error) // GetUsers returns a list of all the usernames GetUsers() ([]User, error) // UpdateUser updates the role of the given users UpdateUser(username, role string) error // DeleteUser deletes the given user DeleteUser(username string) error // 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 // DeleteBootImages delete BootImages from the data store DeleteBootImages(names []string) 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) // FindTags returns a nodeset.NodeSet of all the hosts with the given tags FindTags(tags []string) (*nodeset.NodeSet, error) // MatchTags returns a nodeset.NodeSet of all the hosts with the all given tags MatchTags(tags []string) (*nodeset.NodeSet, error) // ProvisionHosts sets all hosts in the given NodeSet to provision (true) or unprovision (false) ProvisionHosts(ns *nodeset.NodeSet, provision bool) error // TagHosts adds tags to all hosts in the given NodeSet TagHosts(ns *nodeset.NodeSet, tags []string) error // UntagHosts removes tags from all hosts in the given NodeSet UntagHosts(ns *nodeset.NodeSet, tags []string) error // StoreHosts stores a host 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 // DeleteHosts deletes all hosts in the given nodeset.NodeSet from the data store. DeleteHosts(ns *nodeset.NodeSet) 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 Endpoints ¶ added in v0.0.8
type Endpoints struct {
// contains filtered or unexported fields
}
func NewEndpoints ¶ added in v0.0.8
func (*Endpoints) BootFileURL ¶ added in v0.0.8
func (*Endpoints) CloudInitURL ¶ added in v0.0.8
func (*Endpoints) CompleteURL ¶ added in v0.0.8
func (*Endpoints) IgnitionURL ¶ added in v0.0.8
func (*Endpoints) KickstartURL ¶ added in v0.0.8
func (*Endpoints) KickstartURLParts ¶ added in v0.0.9
func (*Endpoints) LiveImageURL ¶ added in v0.0.8
func (*Endpoints) MetaDataURL ¶ added in v0.0.8
func (*Endpoints) ProvisionURL ¶ added in v0.0.8
func (*Endpoints) ProxmoxURL ¶ added in v0.0.12
func (*Endpoints) UserDataURL ¶ added in v0.0.8
func (*Endpoints) VendorDataURL ¶ added in v0.0.8
type Host ¶
type Host struct { ID ksuid.KSUID `json:"id,omitempty"` Name string `json:"name" validate:"required,hostname"` Interfaces []*NetInterface `json:"interfaces"` Bonds []*Bond `json:"bonds"` Provision bool `json:"provision"` Firmware firmware.Build `json:"firmware"` BootImage string `json:"boot_image"` Tags []string `json:"tags"` }
func (*Host) BootInterface ¶ added in v0.0.5
func (h *Host) BootInterface() *NetInterface
func (*Host) HasAnyTags ¶ added in v0.0.8
func (*Host) Interface ¶
func (h *Host) Interface(mac net.HardwareAddr) *NetInterface
func (*Host) InterfaceBMC ¶
func (h *Host) InterfaceBMC() *NetInterface
func (*Host) InterfaceBonded ¶ added in v0.0.11
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 netip.Prefix `json:"ip"` FQDN string `json:"fqdn"` BMC bool `json:"bmc"` VLAN string `json:"vlan"` MTU uint16 `json:"mtu,omitempty"` }
func (*NetInterface) Addr ¶ added in v0.0.8
func (n *NetInterface) Addr() netip.Addr
func (*NetInterface) AddrString ¶ added in v0.0.8
func (n *NetInterface) AddrString() string
func (*NetInterface) CIDR ¶ added in v0.0.8
func (n *NetInterface) CIDR() string
func (*NetInterface) DNS ¶ added in v0.0.8
func (n *NetInterface) DNS() []net.IP
func (*NetInterface) DNSList ¶ added in v0.0.8
func (n *NetInterface) DNSList() []string
func (*NetInterface) Domain ¶ added in v0.0.9
func (n *NetInterface) Domain() string
func (*NetInterface) DomainSearch ¶ added in v0.0.8
func (n *NetInterface) DomainSearch() []string
func (*NetInterface) Gateway ¶ added in v0.0.8
func (n *NetInterface) Gateway() netip.Addr
func (*NetInterface) HostName ¶ added in v0.0.9
func (n *NetInterface) HostName() string
func (*NetInterface) HostNameIndex ¶ added in v0.0.11
func (n *NetInterface) HostNameIndex(idx int) string
func (*NetInterface) InterfaceMTU ¶ added in v0.0.8
func (n *NetInterface) InterfaceMTU() uint16
func (*NetInterface) MarshalJSON ¶
func (n *NetInterface) MarshalJSON() ([]byte, error)
func (*NetInterface) Netmask ¶ added in v0.0.8
func (n *NetInterface) Netmask() net.IPMask
func (*NetInterface) NetmaskString ¶ added in v0.0.8
func (n *NetInterface) NetmaskString() string
func (*NetInterface) ShortName ¶ added in v0.0.9
func (n *NetInterface) ShortName() string
func (*NetInterface) ToStdAddr ¶ added in v0.0.8
func (n *NetInterface) ToStdAddr() net.IP
func (*NetInterface) UnmarshalJSON ¶
func (n *NetInterface) UnmarshalJSON(data []byte) error