backend

package
v3.8.5+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 44 Imported by: 0

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

View Source
const (
	ValidationError     = "ValidationError"
	TemplateRenderError = "TemplateRenderError"
	StillInUseError     = "StillInUseError"
)

Variables

This section is empty.

Functions

func AddToCache

func AddToCache(l logger.Logger, la, ra net.IP)

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 BasicContent() store.Store

func DefaultIP

func DefaultIP(l logger.Logger) net.IP

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 Fill

func Fill(t store.KeySaver)

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

func LocalFor(l logger.Logger, ra net.IP) net.IP

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 ModelToBackend

func ModelToBackend(m models.Model) store.KeySaver

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 AuthSaver

type AuthSaver interface {
	AuthKey() string
}

type BootEnv

type BootEnv struct {
	*models.BootEnv
	// contains filtered or unexported fields
}

BootEnv encapsulates the machine-agnostic information needed by the provisioner to set up a boot environment.

swagger:model

func AsBootEnv

func AsBootEnv(o models.Model) *BootEnv

func AsBootEnvs

func AsBootEnvs(o []models.Model) []*BootEnv

func (*BootEnv) AddDynamicTree

func (b *BootEnv) AddDynamicTree()

func (*BootEnv) AfterDelete

func (b *BootEnv) AfterDelete()

func (*BootEnv) AfterSave

func (b *BootEnv) AfterSave()

func (*BootEnv) Backend

func (b *BootEnv) Backend() store.Store

func (*BootEnv) BeforeDelete

func (b *BootEnv) BeforeDelete() error

func (*BootEnv) BeforeSave

func (b *BootEnv) BeforeSave() error

func (*BootEnv) Indexes

func (b *BootEnv) Indexes() map[string]index.Maker

func (*BootEnv) Locks

func (b *BootEnv) Locks(action string) []string

func (*BootEnv) NetBoot

func (b *BootEnv) NetBoot() bool

func (*BootEnv) New

func (b *BootEnv) New() store.KeySaver

func (*BootEnv) OnLoad

func (b *BootEnv) OnLoad() error

func (*BootEnv) Render

func (b *BootEnv) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers

func (*BootEnv) SaveClean

func (obj *BootEnv) SaveClean() store.KeySaver

func (*BootEnv) SetReadOnly

func (obj *BootEnv) SetReadOnly(b bool)

func (*BootEnv) Validate

func (b *BootEnv) Validate()

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) LocalIP

func (p *DataTracker) LocalIP(remote net.IP) string

func (*DataTracker) LogFor

func (p *DataTracker) LogFor(s string) logger.Logger

func (*DataTracker) MacToMachineUUID

func (p *DataTracker) MacToMachineUUID(mac string) string

func (*DataTracker) Pref

func (p *DataTracker) Pref(name string) (string, error)

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

type FileSystem struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (fs *FileSystem) AddDynamicFile(fsPath string, t func(net.IP) (io.Reader, error))

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

func (fs *FileSystem) AddDynamicTree(fsPath string, t func(string) (io.Reader, error))

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

func (fs *FileSystem) Open(p string, remoteIP net.IP) (io.Reader, error)

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

func (fs *FileSystem) TftpResponder() func(string, net.IP) (io.Reader, error)

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

type Job struct {
	*models.Job
	// contains filtered or unexported fields
}

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 AsJob

func AsJob(o models.Model) *Job

func AsJobs

func AsJobs(o []models.Model) []*Job

func (*Job) AfterSave

func (j *Job) AfterSave()

func (*Job) BeforeDelete

func (j *Job) BeforeDelete() error

func (*Job) BeforeSave

func (j *Job) BeforeSave() error

func (*Job) Indexes

func (j *Job) Indexes() map[string]index.Maker

func (*Job) Locks

func (j *Job) Locks(action string) []string

func (*Job) Log

func (j *Job) Log(rt *RequestTracker, src io.Reader) error

func (*Job) LogPath

func (j *Job) LogPath(rt *RequestTracker) string

func (*Job) New

func (j *Job) New() store.KeySaver

func (*Job) OnChange

func (j *Job) OnChange(oldThing store.KeySaver) error

func (*Job) OnCreate

func (j *Job) OnCreate() error

func (*Job) OnLoad

func (j *Job) OnLoad() error

func (*Job) RenderActions

func (j *Job) RenderActions(rt *RequestTracker) ([]*models.JobAction, error)

func (*Job) SaveClean

func (obj *Job) SaveClean() store.KeySaver

func (*Job) SetReadOnly

func (obj *Job) SetReadOnly(b bool)

func (*Job) UUID

func (j *Job) UUID() string

func (*Job) Validate

func (j *Job) Validate()

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

type Lease struct {
	*models.Lease
	// contains filtered or unexported fields
}

Lease models a DHCP Lease swagger:model

func AsLease

func AsLease(o models.Model) *Lease

func AsLeases

func AsLeases(o []models.Model) []*Lease

func (*Lease) BeforeSave

func (l *Lease) BeforeSave() error

func (*Lease) Indexes

func (l *Lease) Indexes() map[string]index.Maker

func (*Lease) Locks

func (l *Lease) Locks(action string) []string

func (*Lease) New

func (l *Lease) New() store.KeySaver

func (*Lease) OnChange

func (l *Lease) OnChange(oldThing store.KeySaver) error

func (*Lease) OnCreate

func (l *Lease) OnCreate() error

func (*Lease) OnLoad

func (l *Lease) OnLoad() error

func (*Lease) Reservation

func (l *Lease) Reservation(rt *RequestTracker) *Reservation

func (*Lease) SaveClean

func (obj *Lease) SaveClean() store.KeySaver

func (*Lease) SetReadOnly

func (obj *Lease) SetReadOnly(b bool)

func (*Lease) Subnet

func (l *Lease) Subnet(rt *RequestTracker) *Subnet

func (*Lease) Validate

func (l *Lease) Validate()

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

type Machine struct {
	*models.Machine
	// contains filtered or unexported fields
}

Machine represents a single bare-metal system that the provisioner should manage the boot environment for. swagger:model

func AsMachine

func AsMachine(o models.Model) *Machine

func AsMachines

func AsMachines(o []models.Model) []*Machine

func (*Machine) AfterDelete

func (n *Machine) AfterDelete()

func (*Machine) AfterSave

func (n *Machine) AfterSave()

func (*Machine) AllowStageChange

func (n *Machine) AllowStageChange()

func (*Machine) BeforeSave

func (n *Machine) BeforeSave() error

func (*Machine) HasProfile

func (n *Machine) HasProfile(name string) bool

func (*Machine) HasTask

func (n *Machine) HasTask(s string) bool

func (*Machine) HexAddress

func (n *Machine) HexAddress() string

HexAddress returns Address in raw hexadecimal format, suitable for pxelinux and elilo usage.

func (*Machine) InRunner

func (obj *Machine) InRunner()

func (*Machine) Indexes

func (n *Machine) Indexes() map[string]index.Maker

func (*Machine) Locks

func (m *Machine) Locks(action string) []string

func (*Machine) New

func (n *Machine) New() store.KeySaver

func (*Machine) OnChange

func (n *Machine) OnChange(oldThing store.KeySaver) error

func (*Machine) OnCreate

func (n *Machine) OnCreate() error

func (*Machine) OnLoad

func (n *Machine) OnLoad() error

func (*Machine) ParameterMaker

func (n *Machine) ParameterMaker(rt *RequestTracker, parameter string) (index.Maker, error)

func (*Machine) Path

func (n *Machine) Path() string

func (*Machine) SaveClean

func (obj *Machine) SaveClean() store.KeySaver

func (*Machine) SetReadOnly

func (obj *Machine) SetReadOnly(b bool)

func (*Machine) ShortName

func (n *Machine) ShortName() string

func (*Machine) Validate

func (n *Machine) Validate()

type Param

type Param struct {
	*models.Param
	// contains filtered or unexported fields
}

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 AsParam

func AsParam(o models.Model) *Param

func AsParams

func AsParams(o []models.Model) []*Param

func (*Param) BeforeSave

func (p *Param) BeforeSave() error

func (*Param) Indexes

func (p *Param) Indexes() map[string]index.Maker

func (*Param) Locks

func (p *Param) Locks(action string) []string

func (*Param) New

func (p *Param) New() store.KeySaver

func (*Param) OnLoad

func (p *Param) OnLoad() error

func (*Param) SaveClean

func (obj *Param) SaveClean() store.KeySaver

func (*Param) SetReadOnly

func (obj *Param) SetReadOnly(b bool)

func (*Param) Validate

func (p *Param) Validate()

func (*Param) ValidateValue

func (p *Param) ValidateValue(val interface{}) error

type Paramer

type Paramer interface {
	models.Model
	GetParams(Stores, bool) map[string]interface{}
	SetParams(Stores, map[string]interface{}) error
	GetParam(Stores, string, bool) (interface{}, bool)
	SetParam(Stores, string, interface{}) error
}

type Plugin

type Plugin struct {
	*models.Plugin
	// contains filtered or unexported fields
}

Plugin represents a single instance of a running plugin. This contains the configuration need to start this plugin instance. swagger:model

func AsPlugin

func AsPlugin(o models.Model) *Plugin

func AsPlugins

func AsPlugins(o []models.Model) []*Plugin

func (*Plugin) BeforeSave

func (n *Plugin) BeforeSave() error

func (*Plugin) Indexes

func (n *Plugin) Indexes() map[string]index.Maker

func (*Plugin) Key

func (n *Plugin) Key() string

func (*Plugin) Locks

func (m *Plugin) Locks(action string) []string

func (*Plugin) New

func (n *Plugin) New() store.KeySaver

func (*Plugin) OnLoad

func (n *Plugin) OnLoad() error

func (*Plugin) Prefix

func (n *Plugin) Prefix() string

func (*Plugin) SaveClean

func (obj *Plugin) SaveClean() store.KeySaver

func (*Plugin) SetReadOnly

func (obj *Plugin) SetReadOnly(b bool)

func (*Plugin) Validate

func (n *Plugin) Validate()

type Pref

type Pref struct {
	*models.Pref
	// contains filtered or unexported fields
}

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.

func AsPref

func AsPref(v models.Model) *Pref

func (*Pref) Locks

func (p *Pref) Locks(action string) []string

func (*Pref) New

func (p *Pref) New() store.KeySaver

type Profile

type Profile struct {
	*models.Profile
	// contains filtered or unexported fields
}

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 AsProfile

func AsProfile(o models.Model) *Profile

func AsProfiles

func AsProfiles(o []models.Model) []*Profile

func (*Profile) BeforeDelete

func (p *Profile) BeforeDelete() error

func (*Profile) BeforeSave

func (p *Profile) BeforeSave() error

func (*Profile) Indexes

func (p *Profile) Indexes() map[string]index.Maker

func (*Profile) Locks

func (p *Profile) Locks(action string) []string

func (*Profile) New

func (p *Profile) New() store.KeySaver

func (*Profile) OnLoad

func (p *Profile) OnLoad() error

func (*Profile) SaveClean

func (obj *Profile) SaveClean() store.KeySaver

func (*Profile) SetReadOnly

func (obj *Profile) SetReadOnly(b bool)

func (*Profile) Validate

func (p *Profile) Validate()

type Publisher

type Publisher interface {
	Publish(event *models.Event) error
	Reserve() error
	Release()
	Unload()
}

* 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 ReadSizer

type ReadSizer interface {
	io.Reader
	Sizer
}

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) ParseUrl

func (r *RenderData) ParseUrl(segment, rawUrl string) (string, error)

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) Install

func (rd *Repo) Install() (string, error)

func (*Repo) JoinedComponents

func (rd *Repo) JoinedComponents() string

func (*Repo) Lines

func (rd *Repo) Lines() (string, error)

func (*Repo) R

func (rd *Repo) R() *RenderData

func (*Repo) Target

func (rd *Repo) Target() string

func (*Repo) UrlFor

func (rd *Repo) UrlFor(component string) string

type RequestTracker

type RequestTracker struct {
	*sync.Mutex
	logger.Logger
	// contains filtered or unexported fields
}

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) ApiURL

func (rt *RequestTracker) ApiURL(remoteIP net.IP) string

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) FileURL

func (rt *RequestTracker) FileURL(remoteIP net.IP) string

func (*RequestTracker) Find

func (rt *RequestTracker) Find(prefix, key string) models.Model

func (*RequestTracker) FindByIndex

func (rt *RequestTracker) FindByIndex(prefix string, idx index.Maker, key string) models.Model

func (*RequestTracker) GetParam

func (rt *RequestTracker) GetParam(obj models.Paramer, key string, aggregate bool) (interface{}, bool)

func (*RequestTracker) GetParams

func (rt *RequestTracker) GetParams(obj models.Paramer, aggregate bool) map[string]interface{}

func (*RequestTracker) Index

func (rt *RequestTracker) Index(name string) *index.Index

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) RawFind

func (rt *RequestTracker) RawFind(prefix, key string) models.Model

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

func (*RequestTracker) SetParams

func (rt *RequestTracker) SetParams(obj models.Paramer, values map[string]interface{}) error

func (*RequestTracker) Update

func (rt *RequestTracker) Update(obj models.Model) (saved bool, err 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) Indexes

func (l *Reservation) Indexes() map[string]index.Maker

func (*Reservation) Locks

func (r *Reservation) Locks(action string) []string

func (*Reservation) New

func (r *Reservation) New() store.KeySaver

func (*Reservation) OnChange

func (r *Reservation) OnChange(oldThing store.KeySaver) error

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 Role

type Role struct {
	*models.Role
	// contains filtered or unexported fields
}

func AsRole

func AsRole(r models.Model) *Role

func AsRoles

func AsRoles(o []models.Model) []*Role

func (*Role) AfterSave

func (r *Role) AfterSave()

func (*Role) BeforeDelete

func (r *Role) BeforeDelete() error

func (*Role) BeforeSave

func (r *Role) BeforeSave() error

func (*Role) CompiledClaims

func (r *Role) CompiledClaims() models.Claims

func (*Role) Indexes

func (r *Role) Indexes() map[string]index.Maker

func (*Role) Locks

func (r *Role) Locks(action string) []string

func (*Role) New

func (r *Role) New() store.KeySaver

func (*Role) OnLoad

func (r *Role) OnLoad() error

func (*Role) SaveClean

func (r *Role) SaveClean() store.KeySaver

func (*Role) Validate

func (r *Role) Validate()

type Sizer

type Sizer interface {
	Size() int64
}

type Stage

type Stage struct {
	*models.Stage
	// contains filtered or unexported fields
}

Stage encapsulates tasks we want to run a machine

swagger:model

func AsStage

func AsStage(o models.Model) *Stage

func AsStages

func AsStages(o []models.Model) []*Stage

func (*Stage) AfterSave

func (s *Stage) AfterSave()

func (*Stage) BeforeDelete

func (s *Stage) BeforeDelete() error

func (*Stage) BeforeSave

func (s *Stage) BeforeSave() error

func (*Stage) HasProfile

func (s *Stage) HasProfile(name string) bool

func (*Stage) HasTask

func (s *Stage) HasTask(ts string) bool

func (*Stage) Indexes

func (s *Stage) Indexes() map[string]index.Maker

func (*Stage) Locks

func (s *Stage) Locks(action string) []string

func (*Stage) New

func (s *Stage) New() store.KeySaver

func (*Stage) OnLoad

func (s *Stage) OnLoad() error

func (*Stage) Render

func (s *Stage) Render(rt *RequestTracker, m *Machine, e models.ErrorAdder) renderers

func (*Stage) SaveClean

func (obj *Stage) SaveClean() store.KeySaver

func (*Stage) SetReadOnly

func (obj *Stage) SetReadOnly(b bool)

func (*Stage) Validate

func (s *Stage) Validate()

type Store

type Store struct {
	sync.Mutex
	index.Index
	// contains filtered or unexported fields
}

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 Stores

type Stores func(string) *Store

type Subnet

type Subnet struct {
	*models.Subnet
	// contains filtered or unexported fields
}

Subnet represents a DHCP Subnet

swagger:model

func AsSubnet

func AsSubnet(o models.Model) *Subnet

func AsSubnets

func AsSubnets(o []models.Model) []*Subnet

func (*Subnet) BeforeSave

func (s *Subnet) BeforeSave() error

func (*Subnet) InActiveRange

func (s *Subnet) InActiveRange(ip net.IP) bool

func (*Subnet) InSubnetRange

func (s *Subnet) InSubnetRange(ip net.IP) bool

func (*Subnet) Indexes

func (s *Subnet) Indexes() map[string]index.Maker

func (*Subnet) LeaseTimeFor

func (s *Subnet) LeaseTimeFor(ip net.IP) time.Duration

func (*Subnet) Locks

func (s *Subnet) Locks(action string) []string

func (*Subnet) New

func (s *Subnet) New() store.KeySaver

func (*Subnet) OnLoad

func (s *Subnet) OnLoad() error

func (*Subnet) SaveClean

func (obj *Subnet) SaveClean() store.KeySaver

func (*Subnet) SetReadOnly

func (obj *Subnet) SetReadOnly(b bool)

func (*Subnet) Validate

func (s *Subnet) Validate()

type Task

type Task struct {
	*models.Task
	// contains filtered or unexported fields
}

Task is a thing that can run on a Machine.

swagger:model

func AsTask

func AsTask(o models.Model) *Task

func AsTasks

func AsTasks(o []models.Model) []*Task

func (*Task) BeforeDelete

func (t *Task) BeforeDelete() error

func (*Task) BeforeSave

func (t *Task) BeforeSave() error

func (*Task) Indexes

func (t *Task) Indexes() map[string]index.Maker

func (*Task) Locks

func (t *Task) Locks(action string) []string

func (*Task) New

func (t *Task) New() store.KeySaver

func (*Task) OnLoad

func (t *Task) OnLoad() error

func (*Task) Render

func (t *Task) Render(rt *RequestTracker, m *Machine, e *models.Error) renderers

func (*Task) SaveClean

func (obj *Task) SaveClean() store.KeySaver

func (*Task) SetReadOnly

func (obj *Task) SetReadOnly(b bool)

func (*Task) Validate

func (t *Task) Validate()

type Template

type Template struct {
	*models.Template
	// contains filtered or unexported fields
}

Template represents a template that will be associated with a boot environment.

swagger:model

func AsTemplate

func AsTemplate(o models.Model) *Template

func AsTemplates

func AsTemplates(o []models.Model) []*Template

func (*Template) AfterSave

func (t *Template) AfterSave()

func (*Template) BeforeDelete

func (t *Template) BeforeDelete() error

func (*Template) BeforeSave

func (t *Template) BeforeSave() error

func (*Template) Indexes

func (p *Template) Indexes() map[string]index.Maker

func (*Template) Locks

func (t *Template) Locks(action string) []string

func (*Template) New

func (t *Template) New() store.KeySaver

func (*Template) OnLoad

func (t *Template) OnLoad() error

func (*Template) SaveClean

func (obj *Template) SaveClean() store.KeySaver

func (*Template) SetReadOnly

func (obj *Template) SetReadOnly(b bool)

func (*Template) Validate

func (t *Template) Validate()

type Tenant

type Tenant struct {
	*models.Tenant
	// contains filtered or unexported fields
}

func AsTenant

func AsTenant(t models.Model) *Tenant

func AsTenants

func AsTenants(o []models.Model) []*Tenant

func (*Tenant) AfterSave

func (t *Tenant) AfterSave()

func (*Tenant) BeforeDelete

func (t *Tenant) BeforeDelete() error

func (*Tenant) BeforeSave

func (t *Tenant) BeforeSave() error

todo: Actually validate that all the items the Tenant references still exist.

func (*Tenant) ExpandedMembers

func (t *Tenant) ExpandedMembers() map[string]map[string]struct{}

func (*Tenant) Indexes

func (t *Tenant) Indexes() map[string]index.Maker

func (*Tenant) Locks

func (t *Tenant) Locks(action string) []string

func (*Tenant) New

func (t *Tenant) New() store.KeySaver

func (*Tenant) OnChange

func (t *Tenant) OnChange(t2 store.KeySaver) error

func (*Tenant) OnCreate

func (t *Tenant) OnCreate() error

func (*Tenant) OnLoad

func (t *Tenant) OnLoad() error

func (*Tenant) SaveClean

func (t *Tenant) SaveClean() store.KeySaver

func (*Tenant) Validate

func (t *Tenant) Validate()

type User

type User struct {
	*models.User
	// contains filtered or unexported fields
}

User is an API user of DigitalRebar Provision swagger:model

func AsUser

func AsUser(o models.Model) *User

func AsUsers

func AsUsers(o []models.Model) []*User

func (*User) AfterDelete

func (u *User) AfterDelete()

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) ChangePassword

func (u *User) ChangePassword(rt *RequestTracker, newPass string) error

func (*User) GenClaim

func (u *User) GenClaim(grantor string, ttl time.Duration, wantedRoles ...string) *DrpCustomClaims

func (*User) Indexes

func (p *User) Indexes() map[string]index.Maker

func (*User) Locks

func (u *User) Locks(action string) []string

func (*User) New

func (u *User) New() store.KeySaver

func (*User) OnLoad

func (u *User) OnLoad() error

func (*User) SaveClean

func (obj *User) SaveClean() store.KeySaver

func (*User) SetReadOnly

func (obj *User) SetReadOnly(b bool)

func (*User) Tenant

func (u *User) Tenant() string

func (*User) Validate

func (u *User) Validate()

type Workflow

type Workflow struct {
	*models.Workflow
	// contains filtered or unexported fields
}

func AsWorkflow

func AsWorkflow(o models.Model) *Workflow

func AsWorkflows

func AsWorkflows(o []models.Model) []*Workflow

func (*Workflow) BeforeSave

func (w *Workflow) BeforeSave() error

func (*Workflow) Indexes

func (w *Workflow) Indexes() map[string]index.Maker

func (*Workflow) Locks

func (w *Workflow) Locks(action string) []string

func (*Workflow) New

func (w *Workflow) New() store.KeySaver

func (*Workflow) OnLoad

func (w *Workflow) OnLoad() error

func (*Workflow) SaveClean

func (w *Workflow) SaveClean() store.KeySaver

func (*Workflow) SetReadOnly

func (w *Workflow) SetReadOnly(b bool)

func (*Workflow) Validate

func (w *Workflow) Validate()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL