Documentation ¶
Overview ¶
backend contains the backend code for DigitalRebar Provision. It has the responsibility for saving and loading all the data we need to the backing store, making sure that said models are valid and remain consistent, making sure that all the links between objects remain consistent, and providing any optimizations needed to make things perform at scale.
Index ¶
- Constants
- func AddToCache(l logger.Logger, la, ra net.IP)
- func BasicContent() store.Store
- func DefaultIP(l logger.Logger) net.IP
- func FakeLeaseFor(rt *RequestTracker, strat, token string, via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation)
- func Fill(t store.KeySaver)
- func FindLease(rt *RequestTracker, strat, token string, req net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, err error)
- func FindOrCreateLease(rt *RequestTracker, strat, token string, req net.IP, via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, fresh bool)
- func LocalFor(l logger.Logger, ra net.IP) net.IP
- func ModelToBackend(m models.Model) store.KeySaver
- func SetLogPublisher(l *logger.Buffer, pubs *Publishers)
- func ValidateDataTrackerStore(fileRoot string, backend store.Store, logger logger.Logger) (hard, soft error)
- func ValidateParams(rt *RequestTracker, e models.ErrorAdder, params map[string]interface{})
- type AuthSaver
- type BootEnv
- func (b *BootEnv) AddDynamicTree()
- func (b *BootEnv) AfterDelete()
- func (b *BootEnv) AfterSave()
- func (b *BootEnv) Backend() store.Store
- func (b *BootEnv) BeforeDelete() error
- func (b *BootEnv) BeforeSave() error
- func (b *BootEnv) Indexes() map[string]index.Maker
- func (b *BootEnv) Locks(action string) []string
- func (b *BootEnv) NetBoot() bool
- func (b *BootEnv) New() store.KeySaver
- func (b *BootEnv) OnLoad() error
- func (b *BootEnv) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers
- func (obj *BootEnv) SaveClean() store.KeySaver
- func (obj *BootEnv) SetReadOnly(b bool)
- func (b *BootEnv) Validate()
- type DataTracker
- func (p *DataTracker) Backup() ([]byte, error)
- func (dt *DataTracker) GetInterfaces() ([]*models.Interface, error)
- func (p *DataTracker) GetToken(tokenString string) (*DrpCustomClaims, error)
- func (p *DataTracker) LocalIP(remote net.IP) string
- func (p *DataTracker) LogFor(s string) logger.Logger
- func (p *DataTracker) MacToMachineUUID(mac string) string
- func (p *DataTracker) Pref(name string) (string, error)
- func (p *DataTracker) Prefs() map[string]string
- func (p *DataTracker) RenderUnknown(rt *RequestTracker) error
- func (p *DataTracker) ReplaceBackend(rt *RequestTracker, st store.Store) (hard, soft error)
- func (p *DataTracker) Request(l logger.Logger, locks ...string) *RequestTracker
- func (p *DataTracker) SealClaims(claims *DrpCustomClaims) (string, error)
- func (p *DataTracker) SetPrefs(rt *RequestTracker, prefs map[string]string) error
- type DrpCustomClaims
- func (d *DrpCustomClaims) AddMachine(uuid string) *DrpCustomClaims
- func (d *DrpCustomClaims) AddRawClaim(scope, action, specific string) *DrpCustomClaims
- func (d *DrpCustomClaims) AddRoles(names ...string) *DrpCustomClaims
- func (d *DrpCustomClaims) AddSecrets(user, grantor, machine string) *DrpCustomClaims
- func (d *DrpCustomClaims) ClaimsList(rt *RequestTracker) []models.Claims
- func (d *DrpCustomClaims) GrantorId() string
- func (d *DrpCustomClaims) HasGrantorId() bool
- func (d *DrpCustomClaims) HasMachineUuid() bool
- func (d *DrpCustomClaims) HasUserId() bool
- func (d *DrpCustomClaims) MachineUuid() string
- func (d *DrpCustomClaims) Seal(m *JwtManager) (string, error)
- func (d *DrpCustomClaims) UserId() string
- func (d *DrpCustomClaims) ValidateSecrets(grantor, user, machine string) bool
- type FileSystem
- func (fs *FileSystem) AddDynamicFile(fsPath string, t func(net.IP) (io.Reader, error))
- func (fs *FileSystem) AddDynamicTree(fsPath string, t func(string) (io.Reader, error))
- func (fs *FileSystem) DelDynamicFile(fsPath string)
- func (fs *FileSystem) DelDynamicTree(fsPath string)
- func (fs *FileSystem) Open(p string, remoteIP net.IP) (io.Reader, error)
- func (fs *FileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (fs *FileSystem) TftpResponder() func(string, net.IP) (io.Reader, error)
- type GrantorClaims
- type Job
- func (j *Job) AfterSave()
- func (j *Job) BeforeDelete() error
- func (j *Job) BeforeSave() error
- func (j *Job) Indexes() map[string]index.Maker
- func (j *Job) Locks(action string) []string
- func (j *Job) Log(rt *RequestTracker, src io.Reader) error
- func (j *Job) LogPath(rt *RequestTracker) string
- func (j *Job) New() store.KeySaver
- func (j *Job) OnChange(oldThing store.KeySaver) error
- func (j *Job) OnCreate() error
- func (j *Job) OnLoad() error
- func (j *Job) RenderActions(rt *RequestTracker) ([]*models.JobAction, error)
- func (obj *Job) SaveClean() store.KeySaver
- func (obj *Job) SetReadOnly(b bool)
- func (j *Job) UUID() string
- func (j *Job) Validate()
- type JwtConfig
- type JwtManager
- type Lease
- func (l *Lease) BeforeSave() error
- func (l *Lease) Indexes() map[string]index.Maker
- func (l *Lease) Locks(action string) []string
- func (l *Lease) New() store.KeySaver
- func (l *Lease) OnChange(oldThing store.KeySaver) error
- func (l *Lease) OnCreate() error
- func (l *Lease) OnLoad() error
- func (l *Lease) Reservation(rt *RequestTracker) *Reservation
- func (obj *Lease) SaveClean() store.KeySaver
- func (obj *Lease) SetReadOnly(b bool)
- func (l *Lease) Subnet(rt *RequestTracker) *Subnet
- func (l *Lease) Validate()
- type LeaseNAK
- type Machine
- func (n *Machine) AfterDelete()
- func (n *Machine) AfterSave()
- func (n *Machine) AllowStageChange()
- func (n *Machine) BeforeSave() error
- func (n *Machine) HasProfile(name string) bool
- func (n *Machine) HasTask(s string) bool
- func (n *Machine) HexAddress() string
- func (obj *Machine) InRunner()
- func (n *Machine) Indexes() map[string]index.Maker
- func (m *Machine) Locks(action string) []string
- func (n *Machine) New() store.KeySaver
- func (n *Machine) OnChange(oldThing store.KeySaver) error
- func (n *Machine) OnCreate() error
- func (n *Machine) OnLoad() error
- func (n *Machine) ParameterMaker(rt *RequestTracker, parameter string) (index.Maker, error)
- func (n *Machine) Path() string
- func (obj *Machine) SaveClean() store.KeySaver
- func (obj *Machine) SetReadOnly(b bool)
- func (n *Machine) ShortName() string
- func (n *Machine) Validate()
- type Param
- func (p *Param) BeforeSave() error
- func (p *Param) Indexes() map[string]index.Maker
- func (p *Param) Locks(action string) []string
- func (p *Param) New() store.KeySaver
- func (p *Param) OnLoad() error
- func (obj *Param) SaveClean() store.KeySaver
- func (obj *Param) SetReadOnly(b bool)
- func (p *Param) Validate()
- func (p *Param) ValidateValue(val interface{}) error
- type Paramer
- type Plugin
- func (n *Plugin) BeforeSave() error
- func (n *Plugin) Indexes() map[string]index.Maker
- func (n *Plugin) Key() string
- func (m *Plugin) Locks(action string) []string
- func (n *Plugin) New() store.KeySaver
- func (n *Plugin) OnLoad() error
- func (n *Plugin) Prefix() string
- func (obj *Plugin) SaveClean() store.KeySaver
- func (obj *Plugin) SetReadOnly(b bool)
- func (n *Plugin) Validate()
- type Pref
- type Profile
- func (p *Profile) BeforeDelete() error
- func (p *Profile) BeforeSave() error
- func (p *Profile) Indexes() map[string]index.Maker
- func (p *Profile) Locks(action string) []string
- func (p *Profile) New() store.KeySaver
- func (p *Profile) OnLoad() error
- func (obj *Profile) SaveClean() store.KeySaver
- func (obj *Profile) SetReadOnly(b bool)
- func (p *Profile) Validate()
- type Publisher
- type Publishers
- type ReadSizer
- type RenderData
- func (r *RenderData) ApiURL() string
- func (r *RenderData) BootParams() (string, error)
- func (r *RenderData) CallTemplate(name string, data interface{}) (ret interface{}, err error)
- func (r *RenderData) GenerateInfiniteToken() string
- func (r *RenderData) GenerateProfileToken(profile string, duration int) string
- func (r *RenderData) GenerateToken() string
- func (r *RenderData) InstallRepos() []*Repo
- func (r *RenderData) MachineRepos() []*Repo
- func (r *RenderData) Param(key string) (interface{}, error)
- func (r *RenderData) ParamAsJSON(key string) (string, error)
- func (r *RenderData) ParamAsYAML(key string) (string, error)
- func (r *RenderData) ParamExists(key string) bool
- func (r *RenderData) ParseUrl(segment, rawUrl string) (string, error)
- func (r *RenderData) ProvisionerAddress() string
- func (r *RenderData) ProvisionerURL() string
- func (r *RenderData) Repos(tags ...string) []*Repo
- type Repo
- type RequestTracker
- func (rt *RequestTracker) AddParam(obj models.Paramer, key string, val interface{}) error
- func (rt *RequestTracker) AllLocked(thunk func(Stores))
- func (rt *RequestTracker) ApiURL(remoteIP net.IP) string
- func (rt *RequestTracker) Create(obj models.Model) (saved bool, err error)
- func (rt *RequestTracker) DelParam(obj models.Paramer, key string) (interface{}, error)
- func (rt *RequestTracker) Do(thunk func(Stores))
- func (rt *RequestTracker) FileURL(remoteIP net.IP) string
- func (rt *RequestTracker) Find(prefix, key string) models.Model
- func (rt *RequestTracker) FindByIndex(prefix string, idx index.Maker, key string) models.Model
- func (rt *RequestTracker) GetParam(obj models.Paramer, key string, aggregate bool) (interface{}, bool)
- func (rt *RequestTracker) GetParams(obj models.Paramer, aggregate bool) map[string]interface{}
- func (rt *RequestTracker) Index(name string) *index.Index
- func (rt *RequestTracker) MachineForMac(mac string) *Machine
- func (rt *RequestTracker) Patch(obj models.Model, key string, patch jsonpatch2.Patch) (models.Model, error)
- func (rt *RequestTracker) Prefs() map[string]string
- func (rt *RequestTracker) Publish(prefix, action, key string, ref interface{}) error
- func (rt *RequestTracker) PublishEvent(e *models.Event) error
- func (rt *RequestTracker) RawFind(prefix, key string) models.Model
- func (rt *RequestTracker) Remove(obj models.Model) (removed bool, err error)
- func (rt *RequestTracker) Save(obj models.Model) (saved bool, err error)
- func (rt *RequestTracker) SealClaims(claims *DrpCustomClaims) (string, error)
- func (rt *RequestTracker) SetParam(obj models.Paramer, key string, val interface{}) error
- func (rt *RequestTracker) SetParams(obj models.Paramer, values map[string]interface{}) error
- func (rt *RequestTracker) Update(obj models.Model) (saved bool, err error)
- type Reservation
- func (r *Reservation) BeforeSave() error
- func (l *Reservation) Indexes() map[string]index.Maker
- func (r *Reservation) Locks(action string) []string
- func (r *Reservation) New() store.KeySaver
- func (r *Reservation) OnChange(oldThing store.KeySaver) error
- func (r *Reservation) OnCreate() error
- func (r *Reservation) OnLoad() error
- func (obj *Reservation) SaveClean() store.KeySaver
- func (obj *Reservation) SetReadOnly(b bool)
- func (r *Reservation) Validate()
- type Role
- func (r *Role) AfterSave()
- func (r *Role) BeforeDelete() error
- func (r *Role) BeforeSave() error
- func (r *Role) CompiledClaims() models.Claims
- func (r *Role) Indexes() map[string]index.Maker
- func (r *Role) Locks(action string) []string
- func (r *Role) New() store.KeySaver
- func (r *Role) OnLoad() error
- func (r *Role) SaveClean() store.KeySaver
- func (r *Role) Validate()
- type Sizer
- type Stage
- func (s *Stage) AfterSave()
- func (s *Stage) BeforeDelete() error
- func (s *Stage) BeforeSave() error
- func (s *Stage) HasProfile(name string) bool
- func (s *Stage) HasTask(ts string) bool
- func (s *Stage) Indexes() map[string]index.Maker
- func (s *Stage) Locks(action string) []string
- func (s *Stage) New() store.KeySaver
- func (s *Stage) OnLoad() error
- func (s *Stage) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers
- func (obj *Stage) SaveClean() store.KeySaver
- func (obj *Stage) SetReadOnly(b bool)
- func (s *Stage) Validate()
- type Store
- type Stores
- type Subnet
- func (s *Subnet) BeforeSave() error
- func (s *Subnet) InActiveRange(ip net.IP) bool
- func (s *Subnet) InSubnetRange(ip net.IP) bool
- func (s *Subnet) Indexes() map[string]index.Maker
- func (s *Subnet) LeaseTimeFor(ip net.IP) time.Duration
- func (s *Subnet) Locks(action string) []string
- func (s *Subnet) New() store.KeySaver
- func (s *Subnet) OnLoad() error
- func (obj *Subnet) SaveClean() store.KeySaver
- func (obj *Subnet) SetReadOnly(b bool)
- func (s *Subnet) Validate()
- type Task
- func (t *Task) BeforeDelete() error
- func (t *Task) BeforeSave() error
- func (t *Task) Indexes() map[string]index.Maker
- func (t *Task) Locks(action string) []string
- func (t *Task) New() store.KeySaver
- func (t *Task) OnLoad() error
- func (t *Task) Render(rt *RequestTracker, m *Machine, e *models.Error) renderers
- func (obj *Task) SaveClean() store.KeySaver
- func (obj *Task) SetReadOnly(b bool)
- func (t *Task) Validate()
- type Template
- func (t *Template) AfterSave()
- func (t *Template) BeforeDelete() error
- func (t *Template) BeforeSave() error
- func (p *Template) Indexes() map[string]index.Maker
- func (t *Template) Locks(action string) []string
- func (t *Template) New() store.KeySaver
- func (t *Template) OnLoad() error
- func (obj *Template) SaveClean() store.KeySaver
- func (obj *Template) SetReadOnly(b bool)
- func (t *Template) Validate()
- type Tenant
- func (t *Tenant) AfterSave()
- func (t *Tenant) BeforeDelete() error
- func (t *Tenant) BeforeSave() error
- func (t *Tenant) ExpandedMembers() map[string]map[string]struct{}
- func (t *Tenant) Indexes() map[string]index.Maker
- func (t *Tenant) Locks(action string) []string
- func (t *Tenant) New() store.KeySaver
- func (t *Tenant) OnChange(t2 store.KeySaver) error
- func (t *Tenant) OnCreate() error
- func (t *Tenant) OnLoad() error
- func (t *Tenant) SaveClean() store.KeySaver
- func (t *Tenant) Validate()
- type User
- func (u *User) AfterDelete()
- func (u *User) BeforeSave() error
- func (u *User) ChangePassword(rt *RequestTracker, newPass string) error
- func (u *User) GenClaim(grantor string, ttl time.Duration, wantedRoles ...string) *DrpCustomClaims
- func (p *User) Indexes() map[string]index.Maker
- func (u *User) Locks(action string) []string
- func (u *User) New() store.KeySaver
- func (u *User) OnLoad() error
- func (obj *User) SaveClean() store.KeySaver
- func (obj *User) SetReadOnly(b bool)
- func (u *User) Tenant() string
- func (u *User) Validate()
- type Workflow
- func (w *Workflow) BeforeSave() error
- func (w *Workflow) Indexes() map[string]index.Maker
- func (w *Workflow) Locks(action string) []string
- func (w *Workflow) New() store.KeySaver
- func (w *Workflow) OnLoad() error
- func (w *Workflow) SaveClean() store.KeySaver
- func (w *Workflow) SetReadOnly(b bool)
- func (w *Workflow) Validate()
Constants ¶
const ( ValidationError = "ValidationError" TemplateRenderError = "TemplateRenderError" StillInUseError = "StillInUseError" )
Variables ¶
This section is empty.
Functions ¶
func AddToCache ¶
AddToCache adds a new remote -> local IP address mapping to the connection cache. If the remote address is already in the cache, its corresponding local address is updates and the timeout is bumped. Mappings that have not been accessed with LocalFor or updated with AddToCache will be evicted if not used for more than 10 minutes.
func BasicContent ¶
func DefaultIP ¶
DefaultIP figures out the IP address of the interface that has the default route. It is used as a fallback IP address when we don't have --static-ip set and we cannot find a local -> remote mapping in the cache.
func FakeLeaseFor ¶
func FakeLeaseFor(rt *RequestTracker, strat, token string, via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation)
FakeLeaseFor returns a lease that has zero duration and that should not be saved. It is intended for use when we are acting as a proxy DHCP server or we are acting as a BINL server.
func FindLease ¶
func FindLease(rt *RequestTracker, strat, token string, req net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, err error)
FindLease finds an appropriate matching Lease. If a non-nil error is returned, the DHCP system must NAK the response. If lease and error are nil, the DHCP system must not respond to the request. Otherwise, the lease will be returned with its ExpireTime updated and the Lease saved.
This function should be called in response to a DHCPREQUEST.
func FindOrCreateLease ¶
func FindOrCreateLease(rt *RequestTracker, strat, token string, req net.IP, via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, fresh bool)
FindOrCreateLease will return a lease for the passed information, creating it if it can. If a non-nil Lease is returned, it has been saved and the DHCP system can offer it. If the returned lease is nil, then the DHCP system should not respond.
This function should be called for DHCPDISCOVER.
func LocalFor ¶
LocalFor returns the local IP address that has responded to TFTP or HTTP requests for the given remote IP. It also bumps the timeout.
func SetLogPublisher ¶
func SetLogPublisher(l *logger.Buffer, pubs *Publishers)
func ValidateDataTrackerStore ¶
func ValidateDataTrackerStore(fileRoot string, backend store.Store, logger logger.Logger) (hard, soft error)
This must be locked with ALL locks on the source datatracker from the caller.
func ValidateParams ¶
func ValidateParams(rt *RequestTracker, e models.ErrorAdder, params map[string]interface{})
Types ¶
type BootEnv ¶
BootEnv encapsulates the machine-agnostic information needed by the provisioner to set up a boot environment.
swagger:model
func AsBootEnvs ¶
func (*BootEnv) AddDynamicTree ¶
func (b *BootEnv) AddDynamicTree()
func (*BootEnv) AfterDelete ¶
func (b *BootEnv) AfterDelete()
func (*BootEnv) BeforeDelete ¶
func (*BootEnv) BeforeSave ¶
func (*BootEnv) Render ¶
func (b *BootEnv) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers
func (*BootEnv) SetReadOnly ¶
type DataTracker ¶
type DataTracker struct { logger.Logger FileRoot string LogRoot string OurAddress string ForceOurAddress bool StaticPort, ApiPort int FS *FileSystem Backend store.Store GlobalProfileName string // contains filtered or unexported fields }
DataTracker represents everything there is to know about acting as a dataTracker.
func NewDataTracker ¶
func NewDataTracker(backend store.Store, fileRoot, logRoot, addr string, forceAddr bool, staticPort, apiPort int, logger logger.Logger, defaultPrefs map[string]string, publishers *Publishers) *DataTracker
Create a new DataTracker that will use passed store to save all operational data
func (*DataTracker) Backup ¶
func (p *DataTracker) Backup() ([]byte, error)
func (*DataTracker) GetInterfaces ¶
func (dt *DataTracker) GetInterfaces() ([]*models.Interface, error)
func (*DataTracker) GetToken ¶
func (p *DataTracker) GetToken(tokenString string) (*DrpCustomClaims, error)
func (*DataTracker) MacToMachineUUID ¶
func (p *DataTracker) MacToMachineUUID(mac string) string
func (*DataTracker) Prefs ¶
func (p *DataTracker) Prefs() map[string]string
func (*DataTracker) RenderUnknown ¶
func (p *DataTracker) RenderUnknown(rt *RequestTracker) error
func (*DataTracker) ReplaceBackend ¶
func (p *DataTracker) ReplaceBackend(rt *RequestTracker, st store.Store) (hard, soft error)
Assumes that all locks are held
func (*DataTracker) Request ¶
func (p *DataTracker) Request(l logger.Logger, locks ...string) *RequestTracker
func (*DataTracker) SealClaims ¶
func (p *DataTracker) SealClaims(claims *DrpCustomClaims) (string, error)
func (*DataTracker) SetPrefs ¶
func (p *DataTracker) SetPrefs(rt *RequestTracker, prefs map[string]string) error
type DrpCustomClaims ¶
type DrpCustomClaims struct { DrpClaims []*models.Claim `json:"drp_claims"` DrpRoles []string GrantorClaims GrantorClaims `json:"grantor_claims"` jwt.StandardClaims }
DrpCustomClaims is a JWT token that contains a list of all the things this token allows access to.
func NewClaim ¶
func NewClaim(user, grantor string, ttl time.Duration) *DrpCustomClaims
NewClaim creates a new, unsigned Token that doesn't allow access to anything. You must call Seal() to turn this into a signed JWT token.
func (*DrpCustomClaims) AddMachine ¶
func (d *DrpCustomClaims) AddMachine(uuid string) *DrpCustomClaims
Set the specific secrets
func (*DrpCustomClaims) AddRawClaim ¶
func (d *DrpCustomClaims) AddRawClaim(scope, action, specific string) *DrpCustomClaims
AddRawClaim adds a discrete Claim to our custom Token class.
func (*DrpCustomClaims) AddRoles ¶
func (d *DrpCustomClaims) AddRoles(names ...string) *DrpCustomClaims
func (*DrpCustomClaims) AddSecrets ¶
func (d *DrpCustomClaims) AddSecrets(user, grantor, machine string) *DrpCustomClaims
Set the specific secrets
func (*DrpCustomClaims) ClaimsList ¶
func (d *DrpCustomClaims) ClaimsList(rt *RequestTracker) []models.Claims
func (*DrpCustomClaims) GrantorId ¶
func (d *DrpCustomClaims) GrantorId() string
func (*DrpCustomClaims) HasGrantorId ¶
func (d *DrpCustomClaims) HasGrantorId() bool
func (*DrpCustomClaims) HasMachineUuid ¶
func (d *DrpCustomClaims) HasMachineUuid() bool
func (*DrpCustomClaims) HasUserId ¶
func (d *DrpCustomClaims) HasUserId() bool
func (*DrpCustomClaims) MachineUuid ¶
func (d *DrpCustomClaims) MachineUuid() string
func (*DrpCustomClaims) Seal ¶
func (d *DrpCustomClaims) Seal(m *JwtManager) (string, error)
Seal turns our custom Token class into a signed JWT Token.
func (*DrpCustomClaims) UserId ¶
func (d *DrpCustomClaims) UserId() string
func (*DrpCustomClaims) ValidateSecrets ¶
func (d *DrpCustomClaims) ValidateSecrets(grantor, user, machine string) bool
type FileSystem ¶
FileSystem provides the routines to allow the static HTTP and TFTP services to render templates on demand..
func NewFS ¶
func NewFS(backingFSPath string, logger logger.Logger) *FileSystem
NewFS creates a new initialized filesystem that will fall back to serving files from backingFSPath if there is not a template to be rendered.
func (*FileSystem) AddDynamicFile ¶
AddDynamicFile adds a lookaside that handles rendering a file that should be generated on the fly. fsPath is the path where the dynamic lookaside lives, and the passed-in function will be called with the IP address of the system making the request.
func (*FileSystem) AddDynamicTree ¶
AddDynamicTree adds a lookaside responsible for wholesale impersonation of a directory tree. fsPath indicates where AddDynamicTree will start handling all read requests, and the passed-in function will be called with the full path to whatever was being requested.
func (*FileSystem) DelDynamicFile ¶
func (fs *FileSystem) DelDynamicFile(fsPath string)
DelDynamicFile removes a lookaside registered for fsPath, if any.
func (*FileSystem) DelDynamicTree ¶
func (fs *FileSystem) DelDynamicTree(fsPath string)
DelDynamicTree removes a lookaside responsible for wholesale impersonation of a directory tree.
func (*FileSystem) Open ¶
Open tests for the existence of a lookaside for file read request. The returned Reader amd error contains the results of running the lookaside function if one is present. If both the reader and error are nil, FileSystem should fall back to serving a static file.
func (*FileSystem) ServeHTTP ¶
func (fs *FileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for the FileSystem.
func (*FileSystem) TftpResponder ¶
TftpResponder returns a function that allows the TFTP midlayer to serve files from the FileSystem.
type GrantorClaims ¶
type GrantorClaims struct { GrantorId string `json:"grantor_id"` GrantorSecret string `json:"grantor_secret"` UserId string `json:"user_id"` UserSecret string `json:"user_secret"` MachineUuid string `json:"machine_uuid"` MachineSecret string `json:"machine_secret"` }
Grantor Claims allow for the token to be validated against the granting user, the current user, and the machine. Each of those object can have a secret that if changed on the user object will invalid the token.
This allows for mass revocation at a machine, grantor, or user level.
func (*GrantorClaims) Validate ¶
func (gc *GrantorClaims) Validate(grantor, user, machine string) bool
If present, we should validate them.
type Job ¶
Job represents a task that is running (or has run) on a machine. The job create workflow I envision works like this:
- POST to api/v3/jobs with a body containing {"Machine": "a-machine-uuid"} If there is no current job, or the current job is "failed", a new job is created for the Task indexed by CurrentTask. If the current job is "finished", the machine CurrentTask is incremented. If that causes CurrentTask to go past the end of the Tasks list for the machine, no job is created and the API returns a 204. If the current job is in the imcomplete state, that job is returned with a 202. Otherwise a new job is created and is returned with a 201. If there is a current job that is neither "incomplete", "failed", nor "finished", the POST fails. The new job will be created with its Previous value set to the machine's CurrentJob, and the machine's CurrentJob is updated with the UUID of the new job.
- When a new Job is created, it makes a RenderData for the templates contained in the Task the job was created against. The client will be able to retrieve the rendered templates via GET from api/v3/jobs/:job-id/templates.
- The client will place or execute the templates based on whether there is a Path associated with the expanded Template in the order that the jobs/:id/templates API endpoint returns them in. As it does so, it will log its progress via POST to jobs/:id/log.
* If any job operation fails, the client will update the job status to "failed".
* If all job operations succeed, the client will update the job status to "finished"
* On provisioner startup, all machine CurrentJobs are set to "failed" if they are not "finished"
swagger:model
func (*Job) BeforeDelete ¶
func (*Job) BeforeSave ¶
func (*Job) LogPath ¶
func (j *Job) LogPath(rt *RequestTracker) string
func (*Job) RenderActions ¶
func (j *Job) RenderActions(rt *RequestTracker) ([]*models.JobAction, error)
func (*Job) SetReadOnly ¶
type JwtConfig ¶
type JwtConfig struct { // digital signing method, defaults to jwt.SigningMethodHS256 (SHA256) Method jwt.SigningMethod }
Config configures a Manager.
type JwtManager ¶
type JwtManager struct {
// contains filtered or unexported fields
}
Manager is a JSON Web Token (JWT) Provider which create or retrieves tokens with a particular signing key and options.
func NewJwtManager ¶
func NewJwtManager(key []byte, configs ...JwtConfig) *JwtManager
New creates a new Manager which provides JWTs using the given signing key. Defaults to signing with SHA256 HMAC (jwt.SigningMethodHS256)
type Lease ¶
Lease models a DHCP Lease swagger:model
func (*Lease) BeforeSave ¶
func (*Lease) Reservation ¶
func (l *Lease) Reservation(rt *RequestTracker) *Reservation
func (*Lease) SetReadOnly ¶
func (*Lease) Subnet ¶
func (l *Lease) Subnet(rt *RequestTracker) *Subnet
type LeaseNAK ¶
type LeaseNAK error
LeaseNAK is the error that shall be returned when we cannot give a system the IP address it requested. If FindLease or FindOrCreateLease return this as their error, then the DHCP midlayer must NAK the request.
type Machine ¶
Machine represents a single bare-metal system that the provisioner should manage the boot environment for. swagger:model
func AsMachines ¶
func (*Machine) AfterDelete ¶
func (n *Machine) AfterDelete()
func (*Machine) AllowStageChange ¶
func (n *Machine) AllowStageChange()
func (*Machine) BeforeSave ¶
func (*Machine) HasProfile ¶
func (*Machine) HexAddress ¶
HexAddress returns Address in raw hexadecimal format, suitable for pxelinux and elilo usage.
func (*Machine) ParameterMaker ¶
func (*Machine) SetReadOnly ¶
type Param ¶
Param represents metadata about a Parameter or a Preference. Specifically, it contains a description of what the information is for, detailed documentation about the param, and a JSON schema that the param must match to be considered valid. swagger:model
func (*Param) BeforeSave ¶
func (*Param) SetReadOnly ¶
func (*Param) ValidateValue ¶
type Plugin ¶
Plugin represents a single instance of a running plugin. This contains the configuration need to start this plugin instance. swagger:model
func (*Plugin) BeforeSave ¶
func (*Plugin) SetReadOnly ¶
type Pref ¶
Pref tracks a global DigitalRebar Provision preference -- things like the bootenv to use for unknown systems trying to PXE boot to us, the default bootenv for known systems, etc.
type Profile ¶
Profile represents a set of key/values to use in template expansion.
There is one special profile named 'global' that acts as a global set of parameters for the system.
These can be assigned to a machine's profile list. swagger:model
func AsProfiles ¶
func (*Profile) BeforeDelete ¶
func (*Profile) BeforeSave ¶
func (*Profile) SetReadOnly ¶
type Publisher ¶
* NOTE: CRUCIAL: CRITICAL: This could be bad if not adhered. * The Publish, release, and reserve routines must not call loggers * that publish events!
type Publishers ¶
type Publishers struct {
// contains filtered or unexported fields
}
func NewPublishers ¶
func NewPublishers(logger *log.Logger) *Publishers
func (*Publishers) Add ¶
func (p *Publishers) Add(pp Publisher)
func (*Publishers) List ¶
func (p *Publishers) List() []Publisher
func (*Publishers) Remove ¶
func (p *Publishers) Remove(pp Publisher)
type RenderData ¶
type RenderData struct { Machine *rMachine // The Machine that the template is being rendered for. Env *rBootEnv // The boot environment that provided the template. Task *rTask Stage *rStage // contains filtered or unexported fields }
RenderData is the struct that is passed to templates as a source of parameters and useful methods.
func (*RenderData) ApiURL ¶
func (r *RenderData) ApiURL() string
func (*RenderData) BootParams ¶
func (r *RenderData) BootParams() (string, error)
BootParams is a helper function that expands the BootParams template from the boot environment.
func (*RenderData) CallTemplate ¶
func (r *RenderData) CallTemplate(name string, data interface{}) (ret interface{}, err error)
func (*RenderData) GenerateInfiniteToken ¶
func (r *RenderData) GenerateInfiniteToken() string
func (*RenderData) GenerateProfileToken ¶
func (r *RenderData) GenerateProfileToken(profile string, duration int) string
func (*RenderData) GenerateToken ¶
func (r *RenderData) GenerateToken() string
func (*RenderData) InstallRepos ¶
func (r *RenderData) InstallRepos() []*Repo
func (*RenderData) MachineRepos ¶
func (r *RenderData) MachineRepos() []*Repo
func (*RenderData) Param ¶
func (r *RenderData) Param(key string) (interface{}, error)
Param is a helper function for extracting a parameter from Machine.Params
func (*RenderData) ParamAsJSON ¶
func (r *RenderData) ParamAsJSON(key string) (string, error)
func (*RenderData) ParamAsYAML ¶
func (r *RenderData) ParamAsYAML(key string) (string, error)
func (*RenderData) ParamExists ¶
func (r *RenderData) ParamExists(key string) bool
ParamExists is a helper function for determining the existence of a machine parameter.
func (*RenderData) ProvisionerAddress ¶
func (r *RenderData) ProvisionerAddress() string
func (*RenderData) ProvisionerURL ¶
func (r *RenderData) ProvisionerURL() string
func (*RenderData) Repos ¶
func (r *RenderData) Repos(tags ...string) []*Repo
type Repo ¶
type Repo struct { Tag string `json:"tag"` OS []string `json:"os"` URL string `json:"url"` PackageType string `json:"packageType"` RepoType string `json:"repoType"` InstallSource bool `json:"installSource"` SecuritySource bool `json:"securitySource"` Distribution string `json:"distribution"` Components []string `json:"components"` // contains filtered or unexported fields }
func (*Repo) JoinedComponents ¶
func (*Repo) R ¶
func (rd *Repo) R() *RenderData
type RequestTracker ¶
func (*RequestTracker) AddParam ¶
func (rt *RequestTracker) AddParam(obj models.Paramer, key string, val interface{}) error
func (*RequestTracker) AllLocked ¶
func (rt *RequestTracker) AllLocked(thunk func(Stores))
func (*RequestTracker) Create ¶
func (rt *RequestTracker) Create(obj models.Model) (saved bool, err error)
func (*RequestTracker) DelParam ¶
func (rt *RequestTracker) DelParam(obj models.Paramer, key string) (interface{}, error)
func (*RequestTracker) Do ¶
func (rt *RequestTracker) Do(thunk func(Stores))
func (*RequestTracker) FindByIndex ¶
func (*RequestTracker) GetParams ¶
func (rt *RequestTracker) GetParams(obj models.Paramer, aggregate bool) map[string]interface{}
func (*RequestTracker) MachineForMac ¶
func (rt *RequestTracker) MachineForMac(mac string) *Machine
func (*RequestTracker) Patch ¶
func (rt *RequestTracker) Patch(obj models.Model, key string, patch jsonpatch2.Patch) (models.Model, error)
func (*RequestTracker) Prefs ¶
func (rt *RequestTracker) Prefs() map[string]string
func (*RequestTracker) Publish ¶
func (rt *RequestTracker) Publish(prefix, action, key string, ref interface{}) error
func (*RequestTracker) PublishEvent ¶
func (rt *RequestTracker) PublishEvent(e *models.Event) error
func (*RequestTracker) Remove ¶
func (rt *RequestTracker) Remove(obj models.Model) (removed bool, err error)
func (*RequestTracker) Save ¶
func (rt *RequestTracker) Save(obj models.Model) (saved bool, err error)
func (*RequestTracker) SealClaims ¶
func (rt *RequestTracker) SealClaims(claims *DrpCustomClaims) (string, error)
func (*RequestTracker) SetParam ¶
func (rt *RequestTracker) SetParam(obj models.Paramer, key string, val interface{}) error
type Reservation ¶
type Reservation struct { *models.Reservation // contains filtered or unexported fields }
Reservation tracks persistent DHCP IP address reservations.
swagger:model
func AsReservation ¶
func AsReservation(o models.Model) *Reservation
func AsReservations ¶
func AsReservations(o []models.Model) []*Reservation
func (*Reservation) BeforeSave ¶
func (r *Reservation) BeforeSave() error
func (*Reservation) Locks ¶
func (r *Reservation) Locks(action string) []string
func (*Reservation) New ¶
func (r *Reservation) New() store.KeySaver
func (*Reservation) OnCreate ¶
func (r *Reservation) OnCreate() error
func (*Reservation) OnLoad ¶
func (r *Reservation) OnLoad() error
func (*Reservation) SaveClean ¶
func (obj *Reservation) SaveClean() store.KeySaver
func (*Reservation) SetReadOnly ¶
func (obj *Reservation) SetReadOnly(b bool)
func (*Reservation) Validate ¶
func (r *Reservation) Validate()
type Stage ¶
Stage encapsulates tasks we want to run a machine
swagger:model
func (*Stage) BeforeDelete ¶
func (*Stage) BeforeSave ¶
func (*Stage) HasProfile ¶
func (*Stage) Render ¶
func (s *Stage) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers
func (*Stage) SetReadOnly ¶
type Store ¶
dtobjs is an in-memory cache of all the objects we could reference. The implementation of this may need to change from storing a slice of things to a more elaborate datastructure at some point in time. Since that point in time is when the slices are forced out of CPU cache, I am not terribly concerned for now. Until that point is reached, sorting and searching slices is fantastically efficient.
type Subnet ¶
Subnet represents a DHCP Subnet
swagger:model
func (*Subnet) BeforeSave ¶
func (*Subnet) SetReadOnly ¶
type Task ¶
Task is a thing that can run on a Machine.
swagger:model
func (*Task) BeforeDelete ¶
func (*Task) BeforeSave ¶
func (*Task) Render ¶
func (t *Task) Render(rt *RequestTracker, m *Machine, e *models.Error) renderers
func (*Task) SetReadOnly ¶
type Template ¶
Template represents a template that will be associated with a boot environment.
swagger:model
func AsTemplate ¶
func AsTemplates ¶
func (*Template) BeforeDelete ¶
func (*Template) BeforeSave ¶
func (*Template) SetReadOnly ¶
type Tenant ¶
func (*Tenant) BeforeDelete ¶
func (*Tenant) BeforeSave ¶
todo: Actually validate that all the items the Tenant references still exist.
func (*Tenant) ExpandedMembers ¶
type User ¶
User is an API user of DigitalRebar Provision swagger:model
func (*User) AfterDelete ¶
func (u *User) AfterDelete()
func (*User) BeforeSave ¶
func (*User) ChangePassword ¶
func (u *User) ChangePassword(rt *RequestTracker, newPass string) error
func (*User) SetReadOnly ¶
type Workflow ¶
func AsWorkflow ¶
func AsWorkflows ¶
func (*Workflow) BeforeSave ¶
func (*Workflow) SetReadOnly ¶
Source Files ¶
- bootenv.go
- conncache.go
- conncache_linux.go
- dataTracker.go
- dhcpUtils.go
- doc.go
- errors.go
- event.go
- fs.go
- interface_resolver.go
- interfaces.go
- jobs.go
- jwt-utils.go
- lease.go
- machines.go
- param.go
- plugins.go
- preference.go
- profiles.go
- renderData.go
- requestTracker.go
- reservation.go
- roles.go
- stage.go
- subnet.go
- task.go
- template.go
- tenants.go
- user.go
- workflow.go