provision: github.com/digitalrebar/provision/backend Index | Files | Directories

package backend

import "github.com/digitalrebar/provision/backend"

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

Package Files

bootenv.go conncache.go dataTracker.go dhcpOption.go dhcpUtils.go doc.go errors.go event.go fs.go interfaces.go jobs.go jwt-utils.go lease.go machines.go param.go plugins.go preference.go profiles.go renderData.go reservation.go stage.go subnet.go task.go template.go user.go

Constants

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

func AddToCache Uses

func AddToCache(local, remote 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 mapping is marked as used. Mappings that have not been accessed with LocalFor or updated with AddToCache will be marked as unused within 60 seconds, and will be evicted if they are still unused within 60 more seconds.

func AsBootEnvs Uses

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

func AsJobs Uses

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

func AsLeases Uses

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

func AsMachines Uses

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

func AsParams Uses

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

func AsPlugins Uses

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

func AsProfiles Uses

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

func AsReservations Uses

func AsReservations(o []models.Model) []*Reservation

func AsStages Uses

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

func AsSubnets Uses

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

func AsTasks Uses

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

func AsTemplates Uses

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

func AsUsers Uses

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

func BasicContent Uses

func BasicContent() store.Store

func Fill Uses

func Fill(t store.KeySaver)

func LocalFor Uses

func LocalFor(remote 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 marks the mapping as used, delaying its eviction from the cache.

func ModelToBackend Uses

func ModelToBackend(m models.Model) store.KeySaver

func ValidateDataTrackerStore Uses

func ValidateDataTrackerStore(backend store.Store, logger *log.Logger) (hard, soft error)

This must be locked with ALL locks on the source datatracker from the caller.

type AuthSaver Uses

type AuthSaver interface {
    AuthKey() string
}

type BootEnv Uses

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 Uses

func AsBootEnv(o models.Model) *BootEnv

func (*BootEnv) AfterDelete Uses

func (b *BootEnv) AfterDelete()

func (*BootEnv) AfterSave Uses

func (b *BootEnv) AfterSave()

func (*BootEnv) Backend Uses

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

func (*BootEnv) BeforeDelete Uses

func (b *BootEnv) BeforeDelete() error

func (*BootEnv) BeforeSave Uses

func (b *BootEnv) BeforeSave() error

func (*BootEnv) Indexes Uses

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

func (*BootEnv) Locks Uses

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

func (*BootEnv) New Uses

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

func (*BootEnv) OnLoad Uses

func (b *BootEnv) OnLoad() error

func (*BootEnv) Render Uses

func (b *BootEnv) Render(d Stores, m *Machine, e models.ErrorAdder) renderers

func (*BootEnv) SaveClean Uses

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

func (*BootEnv) SetReadOnly Uses

func (obj *BootEnv) SetReadOnly(b bool)

func (*BootEnv) Validate Uses

func (b *BootEnv) Validate()

type Claim Uses

type Claim struct {
    Scope    string `json:"scope"`
    Action   string `json:"action"`
    Specific string `json:"specific"`
}

Claim is an individial specifier for something we are allowed access to.

func (*Claim) Match Uses

func (c *Claim) Match(scope, action, specific string) bool

Match tests to see if this claim allows access for the specified scope, action, and specific item.

If the Claim has `*` for any field, it matches all possible values for that field.

type DataTracker Uses

type DataTracker struct {
    FileRoot            string
    LogRoot             string
    OurAddress          string
    ForceOurAddress     bool
    StaticPort, ApiPort int
    Logger              *log.Logger
    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 Uses

func NewDataTracker(backend store.Store,
    fileRoot, logRoot, addr string, forceAddr bool,
    staticPort, apiPort int,
    logger *log.Logger,
    defaultPrefs map[string]string,
    publishers *Publishers) *DataTracker

Create a new DataTracker that will use passed store to save all operational data

func (*DataTracker) ApiURL Uses

func (p *DataTracker) ApiURL(remoteIP net.IP) string

func (*DataTracker) Backup Uses

func (p *DataTracker) Backup() ([]byte, error)

func (*DataTracker) Create Uses

func (p *DataTracker) Create(d Stores, obj models.Model) (saved bool, err error)

func (*DataTracker) DebugLevel Uses

func (p *DataTracker) DebugLevel(pref string) int

func (*DataTracker) Debugf Uses

func (p *DataTracker) Debugf(pref, f string, args ...interface{})

func (*DataTracker) FileURL Uses

func (p *DataTracker) FileURL(remoteIP net.IP) string

func (*DataTracker) GetInterfaces Uses

func (dt *DataTracker) GetInterfaces() ([]*models.Interface, error)

func (*DataTracker) GetToken Uses

func (p *DataTracker) GetToken(tokenString string) (*DrpCustomClaims, error)

func (*DataTracker) Infof Uses

func (p *DataTracker) Infof(pref, f string, args ...interface{})

func (*DataTracker) LocalIP Uses

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

func (*DataTracker) LockAll Uses

func (p *DataTracker) LockAll() (stores Stores, unlocker func())

func (*DataTracker) LockEnts Uses

func (p *DataTracker) LockEnts(ents ...string) (stores Stores, unlocker func())

LockEnts grabs the requested Store locks a consistent order. It returns a function to get an Index that was requested, and a function that unlocks the taken locks in the right order.

func (*DataTracker) Patch Uses

func (p *DataTracker) Patch(d Stores, obj models.Model, key string, patch jsonpatch2.Patch) (models.Model, error)

func (*DataTracker) Pref Uses

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

func (*DataTracker) Prefs Uses

func (p *DataTracker) Prefs() map[string]string

func (*DataTracker) Printf Uses

func (p *DataTracker) Printf(f string, args ...interface{})

func (*DataTracker) Remove Uses

func (p *DataTracker) Remove(d Stores, obj models.Model) (removed bool, err error)

func (*DataTracker) RenderUnknown Uses

func (p *DataTracker) RenderUnknown(d Stores) error

func (*DataTracker) ReplaceBackend Uses

func (p *DataTracker) ReplaceBackend(st store.Store) (hard, soft error)

Assumes that all locks are held

func (*DataTracker) Save Uses

func (p *DataTracker) Save(d Stores, obj models.Model) (saved bool, err error)

func (*DataTracker) SealClaims Uses

func (p *DataTracker) SealClaims(claims *DrpCustomClaims) (string, error)

func (*DataTracker) SetPrefs Uses

func (p *DataTracker) SetPrefs(d Stores, prefs map[string]string) error

func (*DataTracker) Update Uses

func (p *DataTracker) Update(d Stores, obj models.Model) (saved bool, err error)

type DrpCustomClaims Uses

type DrpCustomClaims struct {
    DrpClaims     []Claim       `json:"drp_claims"`
    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 Uses

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) Add Uses

func (d *DrpCustomClaims) Add(scope, action, specific string) *DrpCustomClaims

Add adds a discrete Claim to our custom Token class.

func (*DrpCustomClaims) AddMachine Uses

func (d *DrpCustomClaims) AddMachine(uuid string) *DrpCustomClaims

Set the specific secrets

func (*DrpCustomClaims) AddSecrets Uses

func (d *DrpCustomClaims) AddSecrets(user, grantor, machine string) *DrpCustomClaims

Set the specific secrets

func (*DrpCustomClaims) GrantorId Uses

func (d *DrpCustomClaims) GrantorId() string

func (*DrpCustomClaims) HasGrantorId Uses

func (d *DrpCustomClaims) HasGrantorId() bool

func (*DrpCustomClaims) HasMachineUuid Uses

func (d *DrpCustomClaims) HasMachineUuid() bool

func (*DrpCustomClaims) HasUserId Uses

func (d *DrpCustomClaims) HasUserId() bool

func (*DrpCustomClaims) MachineUuid Uses

func (d *DrpCustomClaims) MachineUuid() string

func (*DrpCustomClaims) Match Uses

func (d *DrpCustomClaims) Match(scope, action, specific string) bool

Match tests all the claims in this Token to find one that matches.

func (*DrpCustomClaims) Seal Uses

func (d *DrpCustomClaims) Seal(m *JwtManager) (string, error)

Seal turns our custom Token class into a signed JWT Token.

func (*DrpCustomClaims) UserId Uses

func (d *DrpCustomClaims) UserId() string

func (*DrpCustomClaims) ValidateSecrets Uses

func (d *DrpCustomClaims) ValidateSecrets(grantor, user, machine string) bool

type FileSystem Uses

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 Uses

func NewFS(backingFSPath string, logger *log.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) Open Uses

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

Open tests for the existence of a template to be rendered for a file read request. The returned Reader contains the rendered template if there is one, and the returned error contains any rendering errors. If both the reader and error are nil, there is no template to be expanded for p and FileSystem should fall back to serving a static file.

func (*FileSystem) ServeHTTP Uses

func (fs *FileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for the FileSystem.

func (*FileSystem) TftpResponder Uses

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 Uses

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 Uses

func (gc *GrantorClaims) Validate(grantor, user, machine string) bool

If present, we should validate them.

type Job Uses

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 Uses

func AsJob(o models.Model) *Job

func (*Job) AfterSave Uses

func (j *Job) AfterSave()

func (*Job) Backend Uses

func (j *Job) Backend() store.Store

func (*Job) BeforeDelete Uses

func (j *Job) BeforeDelete() error

func (*Job) BeforeSave Uses

func (j *Job) BeforeSave() error

func (*Job) Indexes Uses

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

func (*Job) Locks Uses

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

func (*Job) Log Uses

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

func (*Job) LogPath Uses

func (j *Job) LogPath() string

func (*Job) New Uses

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

func (*Job) OnChange Uses

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

func (*Job) OnCreate Uses

func (j *Job) OnCreate() error

func (*Job) OnLoad Uses

func (j *Job) OnLoad() error

func (*Job) RenderActions Uses

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

func (*Job) SaveClean Uses

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

func (*Job) SetReadOnly Uses

func (obj *Job) SetReadOnly(b bool)

func (*Job) UUID Uses

func (j *Job) UUID() string

func (*Job) Validate Uses

func (j *Job) Validate()

type JwtConfig Uses

type JwtConfig struct {
    // digital signing method, defaults to jwt.SigningMethodHS256 (SHA256)
    Method jwt.SigningMethod
}

Config configures a Manager.

type JwtManager Uses

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 Uses

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 Uses

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

Lease models a DHCP Lease swagger:model

func AsLease Uses

func AsLease(o models.Model) *Lease

func FindLease Uses

func FindLease(dt *DataTracker,
    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 Uses

func FindOrCreateLease(dt *DataTracker,
    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 (*Lease) Backend Uses

func (l *Lease) Backend() store.Store

func (*Lease) BeforeSave Uses

func (l *Lease) BeforeSave() error

func (*Lease) Expire Uses

func (l *Lease) Expire()

func (*Lease) Expired Uses

func (l *Lease) Expired() bool

func (*Lease) Indexes Uses

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

func (*Lease) Invalidate Uses

func (l *Lease) Invalidate()

func (*Lease) Locks Uses

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

func (*Lease) New Uses

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

func (*Lease) OnChange Uses

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

func (*Lease) OnCreate Uses

func (l *Lease) OnCreate() error

func (*Lease) OnLoad Uses

func (l *Lease) OnLoad() error

func (*Lease) Reservation Uses

func (l *Lease) Reservation(d Stores) *Reservation

func (*Lease) SaveClean Uses

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

func (*Lease) SetReadOnly Uses

func (obj *Lease) SetReadOnly(b bool)

func (*Lease) Subnet Uses

func (l *Lease) Subnet(d Stores) *Subnet

func (*Lease) Validate Uses

func (l *Lease) Validate()

type LeaseNAK Uses

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 Uses

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 Uses

func AsMachine(o models.Model) *Machine

func (*Machine) AfterDelete Uses

func (n *Machine) AfterDelete()

func (*Machine) AfterSave Uses

func (n *Machine) AfterSave()

func (*Machine) Backend Uses

func (n *Machine) Backend() store.Store

func (*Machine) BeforeSave Uses

func (n *Machine) BeforeSave() error

func (*Machine) GetParam Uses

func (n *Machine) GetParam(d Stores, key string, aggregate bool) (interface{}, bool)

func (*Machine) GetParams Uses

func (n *Machine) GetParams(d Stores, aggregate bool) map[string]interface{}

func (*Machine) HasProfile Uses

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

func (*Machine) HasTask Uses

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

func (*Machine) HexAddress Uses

func (n *Machine) HexAddress() string

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

func (*Machine) Indexes Uses

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

func (*Machine) Locks Uses

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

func (*Machine) New Uses

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

func (*Machine) OnChange Uses

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

func (*Machine) OnCreate Uses

func (n *Machine) OnCreate() error

func (*Machine) OnLoad Uses

func (n *Machine) OnLoad() error

func (*Machine) ParameterMaker Uses

func (n *Machine) ParameterMaker(d Stores, parameter string) (index.Maker, error)

func (*Machine) Path Uses

func (n *Machine) Path() string

func (*Machine) SaveClean Uses

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

func (*Machine) SetParam Uses

func (n *Machine) SetParam(d Stores, key string, val interface{}) error

func (*Machine) SetParams Uses

func (n *Machine) SetParams(d Stores, values map[string]interface{}) error

func (*Machine) SetReadOnly Uses

func (obj *Machine) SetReadOnly(b bool)

func (*Machine) ShortName Uses

func (n *Machine) ShortName() string

func (*Machine) Validate Uses

func (n *Machine) Validate()

type Param Uses

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 Uses

func AsParam(o models.Model) *Param

func (*Param) Backend Uses

func (p *Param) Backend() store.Store

func (*Param) BeforeSave Uses

func (p *Param) BeforeSave() error

func (*Param) Indexes Uses

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

func (*Param) Locks Uses

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

func (*Param) New Uses

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

func (*Param) OnLoad Uses

func (p *Param) OnLoad() error

func (*Param) SaveClean Uses

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

func (*Param) SetReadOnly Uses

func (obj *Param) SetReadOnly(b bool)

func (*Param) Validate Uses

func (p *Param) Validate()

func (*Param) ValidateValue Uses

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

type Paramer Uses

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 Uses

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 Uses

func AsPlugin(o models.Model) *Plugin

func (*Plugin) Backend Uses

func (n *Plugin) Backend() store.Store

func (*Plugin) BeforeSave Uses

func (n *Plugin) BeforeSave() error

func (*Plugin) GetParam Uses

func (n *Plugin) GetParam(d Stores, key string, aggregate bool) (interface{}, bool)

func (*Plugin) GetParams Uses

func (n *Plugin) GetParams(d Stores, _ bool) map[string]interface{}

func (*Plugin) Indexes Uses

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

func (*Plugin) Key Uses

func (n *Plugin) Key() string

func (*Plugin) Locks Uses

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

func (*Plugin) New Uses

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

func (*Plugin) OnLoad Uses

func (n *Plugin) OnLoad() error

func (*Plugin) Prefix Uses

func (n *Plugin) Prefix() string

func (*Plugin) SaveClean Uses

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

func (*Plugin) SetParam Uses

func (n *Plugin) SetParam(d Stores, key string, val interface{}) error

func (*Plugin) SetParams Uses

func (n *Plugin) SetParams(d Stores, values map[string]interface{}) error

func (*Plugin) SetReadOnly Uses

func (obj *Plugin) SetReadOnly(b bool)

func (*Plugin) Validate Uses

func (n *Plugin) Validate()

type Pref Uses

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 Uses

func AsPref(v models.Model) *Pref

func (*Pref) Backend Uses

func (p *Pref) Backend() store.Store

func (*Pref) Indexes Uses

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

func (*Pref) Locks Uses

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

func (*Pref) New Uses

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

type Profile Uses

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 Uses

func AsProfile(o models.Model) *Profile

func (*Profile) Backend Uses

func (p *Profile) Backend() store.Store

func (*Profile) BeforeDelete Uses

func (p *Profile) BeforeDelete() error

func (*Profile) BeforeSave Uses

func (p *Profile) BeforeSave() error

func (*Profile) GetParam Uses

func (p *Profile) GetParam(d Stores, key string, aggregate bool) (interface{}, bool)

func (*Profile) GetParams Uses

func (p *Profile) GetParams(d Stores, aggregate bool) map[string]interface{}

func (*Profile) Indexes Uses

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

func (*Profile) Locks Uses

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

func (*Profile) New Uses

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

func (*Profile) OnLoad Uses

func (p *Profile) OnLoad() error

func (*Profile) SaveClean Uses

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

func (*Profile) SetParam Uses

func (p *Profile) SetParam(d Stores, key string, val interface{}) error

func (*Profile) SetParams Uses

func (p *Profile) SetParams(d Stores, values map[string]interface{}) error

func (*Profile) SetReadOnly Uses

func (obj *Profile) SetReadOnly(b bool)

func (*Profile) Validate Uses

func (p *Profile) Validate()

type Publisher Uses

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

type Publishers Uses

type Publishers struct {
    // contains filtered or unexported fields
}

func NewPublishers Uses

func NewPublishers(logger *log.Logger) *Publishers

func (*Publishers) Add Uses

func (p *Publishers) Add(pp Publisher)

func (*Publishers) List Uses

func (p *Publishers) List() []Publisher

func (*Publishers) Publish Uses

func (p *Publishers) Publish(t, a, k string, o interface{}) error

func (*Publishers) PublishEvent Uses

func (p *Publishers) PublishEvent(e *models.Event) error

func (*Publishers) Remove Uses

func (p *Publishers) Remove(pp Publisher)

type RenderData Uses

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 Uses

func (r *RenderData) ApiURL() string

func (*RenderData) BootParams Uses

func (r *RenderData) BootParams() (string, error)

BootParams is a helper function that expands the BootParams template from the boot environment.

func (*RenderData) CallTemplate Uses

func (r *RenderData) CallTemplate(name string, data interface{}) (ret interface{}, err error)

func (*RenderData) GenerateInfiniteToken Uses

func (r *RenderData) GenerateInfiniteToken() string

func (*RenderData) GenerateProfileToken Uses

func (r *RenderData) GenerateProfileToken(profile string, duration int) string

func (*RenderData) GenerateToken Uses

func (r *RenderData) GenerateToken() string

func (*RenderData) InstallRepos Uses

func (r *RenderData) InstallRepos() []*Repo

func (*RenderData) MachineRepos Uses

func (r *RenderData) MachineRepos() []*Repo

func (*RenderData) Param Uses

func (r *RenderData) Param(key string) (interface{}, error)

Param is a helper function for extracting a parameter from Machine.Params

func (*RenderData) ParamExists Uses

func (r *RenderData) ParamExists(key string) bool

ParamExists is a helper function for determining the existence of a machine parameter.

func (*RenderData) ParseUrl Uses

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

func (*RenderData) ProvisionerAddress Uses

func (r *RenderData) ProvisionerAddress() string

func (*RenderData) ProvisionerURL Uses

func (r *RenderData) ProvisionerURL() string

func (*RenderData) Repos Uses

func (r *RenderData) Repos(tags ...string) []*Repo

type Repo Uses

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 Uses

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

func (*Repo) JoinedComponents Uses

func (rd *Repo) JoinedComponents() string

func (*Repo) Lines Uses

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

func (*Repo) R Uses

func (rd *Repo) R() *RenderData

func (*Repo) Target Uses

func (rd *Repo) Target() string

func (*Repo) UrlFor Uses

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

type Reservation Uses

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

Reservation tracks persistent DHCP IP address reservations.

swagger:model

func AsReservation Uses

func AsReservation(o models.Model) *Reservation

func (*Reservation) Backend Uses

func (r *Reservation) Backend() store.Store

func (*Reservation) BeforeSave Uses

func (r *Reservation) BeforeSave() error

func (*Reservation) Indexes Uses

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

func (*Reservation) Locks Uses

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

func (*Reservation) New Uses

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

func (*Reservation) OnChange Uses

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

func (*Reservation) OnCreate Uses

func (r *Reservation) OnCreate() error

func (*Reservation) OnLoad Uses

func (r *Reservation) OnLoad() error

func (*Reservation) SaveClean Uses

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

func (*Reservation) SetReadOnly Uses

func (obj *Reservation) SetReadOnly(b bool)

func (*Reservation) Validate Uses

func (r *Reservation) Validate()

type Stage Uses

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

Stage encapsulates tasks we want to run a machine

swagger:model

func AsStage Uses

func AsStage(o models.Model) *Stage

func (*Stage) AfterSave Uses

func (s *Stage) AfterSave()

func (*Stage) Backend Uses

func (s *Stage) Backend() store.Store

func (*Stage) BeforeDelete Uses

func (s *Stage) BeforeDelete() error

func (*Stage) BeforeSave Uses

func (s *Stage) BeforeSave() error

func (*Stage) HasProfile Uses

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

func (*Stage) HasTask Uses

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

func (*Stage) Indexes Uses

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

func (*Stage) Locks Uses

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

func (*Stage) New Uses

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

func (*Stage) OnLoad Uses

func (s *Stage) OnLoad() error

func (*Stage) Render Uses

func (s *Stage) Render(d Stores, m *Machine, e models.ErrorAdder) renderers

func (*Stage) SaveClean Uses

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

func (*Stage) SetReadOnly Uses

func (obj *Stage) SetReadOnly(b bool)

func (*Stage) Validate Uses

func (s *Stage) Validate()

type Store Uses

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 Uses

type Stores func(string) *Store

type Subnet Uses

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

Subnet represents a DHCP Subnet

swagger:model

func AsSubnet Uses

func AsSubnet(o models.Model) *Subnet

func (*Subnet) Backend Uses

func (s *Subnet) Backend() store.Store

func (*Subnet) BeforeSave Uses

func (s *Subnet) BeforeSave() error

func (*Subnet) InActiveRange Uses

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

func (*Subnet) InSubnetRange Uses

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

func (*Subnet) Indexes Uses

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

func (*Subnet) LeaseTimeFor Uses

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

func (*Subnet) Locks Uses

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

func (*Subnet) New Uses

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

func (*Subnet) OnLoad Uses

func (s *Subnet) OnLoad() error

func (*Subnet) SaveClean Uses

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

func (*Subnet) SetReadOnly Uses

func (obj *Subnet) SetReadOnly(b bool)

func (*Subnet) Validate Uses

func (s *Subnet) Validate()

type Task Uses

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

Task is a thing that can run on a Machine.

swagger:model

func AsTask Uses

func AsTask(o models.Model) *Task

func (*Task) Backend Uses

func (t *Task) Backend() store.Store

func (*Task) BeforeDelete Uses

func (t *Task) BeforeDelete() error

func (*Task) BeforeSave Uses

func (t *Task) BeforeSave() error

func (*Task) Indexes Uses

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

func (*Task) Locks Uses

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

func (*Task) New Uses

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

func (*Task) OnLoad Uses

func (t *Task) OnLoad() error

func (*Task) Render Uses

func (t *Task) Render(d Stores, m *Machine, e *models.Error) renderers

func (*Task) SaveClean Uses

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

func (*Task) SetReadOnly Uses

func (obj *Task) SetReadOnly(b bool)

func (*Task) Validate Uses

func (t *Task) Validate()

type Template Uses

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 Uses

func AsTemplate(o models.Model) *Template

func (*Template) AfterSave Uses

func (t *Template) AfterSave()

func (*Template) Backend Uses

func (t *Template) Backend() store.Store

func (*Template) BeforeDelete Uses

func (t *Template) BeforeDelete() error

func (*Template) BeforeSave Uses

func (t *Template) BeforeSave() error

func (*Template) Indexes Uses

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

func (*Template) Locks Uses

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

func (*Template) New Uses

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

func (*Template) OnLoad Uses

func (t *Template) OnLoad() error

func (*Template) SaveClean Uses

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

func (*Template) SetReadOnly Uses

func (obj *Template) SetReadOnly(b bool)

func (*Template) Validate Uses

func (t *Template) Validate()

type User Uses

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

User is an API user of DigitalRebar Provision swagger:model

func AsUser Uses

func AsUser(o models.Model) *User

func (*User) Backend Uses

func (u *User) Backend() store.Store

func (*User) BeforeSave Uses

func (u *User) BeforeSave() error

func (*User) ChangePassword Uses

func (u *User) ChangePassword(d Stores, newPass string) error

func (*User) Indexes Uses

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

func (*User) Locks Uses

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

func (*User) New Uses

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

func (*User) OnLoad Uses

func (u *User) OnLoad() error

func (*User) SaveClean Uses

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

func (*User) SetReadOnly Uses

func (obj *User) SetReadOnly(b bool)

func (*User) Validate Uses

func (u *User) Validate()

Directories

PathSynopsis
index

Package backend imports 39 packages (graph) and is imported by 3 packages. Updated 2017-12-06. Refresh now. Tools for package owners.