models

package
v4.3.0-beta11 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 39 Imported by: 20

Documentation

Index

Constants

View Source
const (
	BsdpOS9       = 0
	BsdpOSX       = 1
	BsdpOSXServer = 2
	BsdpDiags     = 3
)

Variables

View Source
var (
	BadKey   = errors.New("Key must be 32 bytes long")
	BadNonce = errors.New("Nonce must be 24 bytes long")
	Corrupt  = errors.New("SecureData corrupted")
)

Functions

func AllPrefixes

func AllPrefixes() []string

AllPrefixes returns a slice containing the prefix names of all the Models.

func ArchEqual

func ArchEqual(a, b string) bool

ArchEqual returns whether two arches are equal.

func DHCPOptionParser

func DHCPOptionParser(code dhcp.OptionCode) (func(string) ([]byte, error), func([]byte) string)

DHCPOptionParser returns the appropriate string conversion and deconversion functions for a given DHCP option code.

func DecodeYaml

func DecodeYaml(buf []byte, ref interface{}) error

DecodeYaml is a helper function for dealing with user input -- when accepting input from the user, we want to treat both YAML and JSON as first-class citizens. The YAML library we use makes that easier by using the json struct tags for all marshalling and unmarshalling purposes.

Note that the REST API does not use YAML as a wire protocol, so this function should never be used to decode data coming from the provision service.

func DrpSafeFuncMap

func DrpSafeFuncMap() template.FuncMap

func FibBackoff

func FibBackoff(thunk func() error)

FibBackoff takes function and retries it in a fibonacci backup sequence

func GenPatch

func GenPatch(source, target interface{}, paranoid bool) (jsonpatch2.Patch, error)

GenPatch generates a JSON patch that will transform source into target. The generated patch will have all the applicable test clauses.

func Hexaddr

func Hexaddr(addr net.IP) string

func IsSecureData

func IsSecureData(val interface{}) bool

func MergeTemplates

func MergeTemplates(root *template.Template, tmpls []TemplateInfo, e ErrorAdder) *template.Template

func ParseContentPrerequisites

func ParseContentPrerequisites(prereqs string) (map[string]semver.Range, error)

ParseContentPrerequisites is a helper that parses a Prerequisites string from the content bundle metadata and returns a map containing the comparison functions that must pass in order for the content bundle's prerequisites to be satisfied.

func RandString

func RandString(n int) string

RandString returns a random string of n characters The range of characters is limited to the base64 set

func Remarshal

func Remarshal(src, dest interface{}) error

Remarshal remarshals src onto dest.

func SupportedArch

func SupportedArch(s string) (string, bool)

SupportedArch normalizes system architectures and returns whether it is one we know how to normalize.

func UpdateAllScopesWithRawModel

func UpdateAllScopesWithRawModel(prefix string)

UpdateAllScopesWithRawModel adds new role scopes for a specialized RawModel

func ValidMachineName

func ValidMachineName(msg, s string) error

ValidMachineName validates that the string is a valid Machine Name

func ValidName

func ValidName(msg, s string) error

ValidName validates that the string is a valid Name

func ValidParamName

func ValidParamName(msg, s string) error

ValidParamName validates that the string is a valid Param Name

func ValidateIP4

func ValidateIP4(e ErrorAdder, a net.IP)

func ValidateMac

func ValidateMac(e ErrorAdder, mac string)

func ValidateMaybeZeroIP4

func ValidateMaybeZeroIP4(e ErrorAdder, a net.IP)

Types

type Access

type Access struct {
	// ReadOnly tracks if the store for this object is read-only
	// read only: true
	ReadOnly bool
}

Access holds if the object is read-only or not

swagger: model

func (*Access) IsReadOnly

func (a *Access) IsReadOnly() bool

IsReadOnly returns whether the object is read-only. This will be set if the object comes from any content layer other than the working one (provided by a plugin or a content bundle, etc.)

type Accessor

type Accessor interface {
	IsReadOnly() bool
}

Accessor is an interface that objects that can be ReadOnly should satisfy. model object may define a Validate method that can be used to return errors about if the model is valid in the current datatracker.

type Action

type Action struct {
	Model      interface{}
	Plugin     string
	Command    string
	CommandSet string
	Params     map[string]interface{}
}

Action is an additional command that can be added to other Models by a Plugin.

func (*Action) Fill

func (m *Action) Fill()

type Actor

type Actor interface {
	Model
	CanHaveActions() bool
}

Actor interface should be implemented this if you want actions

type ArchInfo

type ArchInfo struct {
	// IsoFile is the name of the ISO file (or other archive)
	// that contains all the necessary information to be able to
	// boot into this BootEnv for a given arch.
	// At a minimum, it must contain a kernel and initrd that
	// can be booted over the network.
	IsoFile string
	// Sha256 should contain the SHA256 checksum for the IsoFile.
	// If it does, the IsoFile will be checked upon upload to make sure
	// it has not been corrupted.
	Sha256 string
	// IsoUrl is the location that IsoFile can be downloaded from, if any.
	// This must be a full URL, including the filename.
	//
	// swagger:strfmt url
	IsoUrl string
	// The partial path to the kernel for the boot environment.  This
	// should be path that the kernel is located at in the OS ISO or
	// install archive.  If empty, this will fall back to the top-level
	// Kernel field in the BootEnv
	//
	// required: true
	Kernel string
	// Partial paths to the initrds that should be loaded for the boot
	// environment. These should be paths that the initrds are located
	// at in the OS ISO or install archive.  If empty, this will fall back
	// to the top-level Initrds field in the BootEnv
	//
	// required: true
	Initrds []string
	// A template that will be expanded to create the full list of
	// boot parameters for the environment.  If empty, this will fall back
	// to the top-level BootParams field in the BootEnv
	//
	// required: true
	BootParams string
	// Loader is the bootloader that should be used for this boot
	// environment.  If left unspecified and not overridden by a subnet
	// or reservation option, the following boot loaders will be used:
	//
	// * lpxelinux.0 on 386-pcbios platforms that are not otherwise using ipxe.
	//
	// * ipxe.pxe on 386-pcbios platforms that already use ipxe.
	//
	// * ipxe.efi on amd64 EFI platforms.
	//
	// * ipxe-arm64.efi on arm64 EFI platforms.
	//
	// This setting will be overridden by Subnet and Reservation
	// options, and it will also only be in effect when dr-provision is
	// the DHCP server of record.
	Loader string
}

ArchInfo tracks information required to make a BootEnv work across different system architectures. It supersedes the matching fields in the BootEnv struct and the OsInfo struct.

func (*ArchInfo) Fill

func (a *ArchInfo) Fill()

type AvailableAction

type AvailableAction struct {
	Provider       string
	Model          string
	Command        string
	RequiredParams []string
	OptionalParams []string
}

AvailableAction is an Action that a Plugin instantiated by a PluginProvider. Assumes that there are parameters on the call in addition to the machine.

swagger:model

func (*AvailableAction) Fill

func (a *AvailableAction) Fill()

type BlobInfo

type BlobInfo struct {
	Path string
	Size int64
}

BlobInfo contains information on an uploaded file or ISO. swagger:model

type BootEnv

type BootEnv struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// The name of the boot environment.  Boot environments that install
	// an operating system must end in '-install'.
	//
	// required: true
	Name string
	// A description of this boot environment.  This should tell what
	// the boot environment is for, any special considerations that
	// should be taken into account when using it, etc.
	Description string
	// Documentation of this boot environment.  This should tell what
	// the boot environment is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// The OS specific information for the boot environment.
	OS OsInfo
	// The templates that should be expanded into files for the
	// boot environment.
	//
	// required: true
	Templates []TemplateInfo
	// The partial path to the kernel for the boot environment.  This
	// should be path that the kernel is located at in the OS ISO or
	// install archive.  Kernel must be non-empty for a BootEnv to be
	// considered net bootable.
	//
	// required: true
	Kernel string
	// Partial paths to the initrds that should be loaded for the boot
	// environment. These should be paths that the initrds are located
	// at in the OS ISO or install archive.
	//
	// required: true
	Initrds []string
	// A template that will be expanded to create the full list of
	// boot parameters for the environment.
	//
	// required: true
	BootParams string
	// The list of extra required parameters for this
	// bootstate. They should be present as Machine.Params when
	// the bootenv is applied to the machine.
	//
	// required: true
	RequiredParams []string
	// The list of extra optional parameters for this
	// bootstate. They can be present as Machine.Params when
	// the bootenv is applied to the machine.  These are more
	// other consumers of the bootenv to know what parameters
	// could additionally be applied to the bootenv by the
	// renderer based upon the Machine.Params
	//
	OptionalParams []string
	// OnlyUnknown indicates whether this bootenv can be used without a
	// machine.  Only bootenvs with this flag set to `true` be used for
	// the unknownBootEnv preference.
	//
	// required: true
	OnlyUnknown bool
	// Loaders contains the boot loaders that should be used for various different network
	// boot scenarios.  It consists of a map of machine type -> partial paths to the bootloaders.
	// Valid machine types are:
	//
	// - 386-pcbios for x86 devices using the legacy bios.
	//
	// - amd64-uefi for x86 devices operating in UEFI mode
	//
	// - arm64-uefi for arm64 devices operating in UEFI mode
	//
	// Other machine types will be added as dr-provision gains support for them.
	//
	// If this map does not contain an entry for the machine type, the DHCP server will fall back to
	// the following entries in this order:
	//
	// - The Loader specified in the ArchInfo struct from this BootEnv, if it exists.
	//
	// - The value specified in the bootloaders param for the machine type specified on the machine, if it exists.
	//
	// - The value specified in the bootloaders param in the global profile, if it exists.
	//
	// - The value specified in the default value for the bootloaders param.
	//
	// - One of the following vaiues:
	//
	//   - lpxelinux.0 for 386-pcbios
	//
	//   - ipxe.efi for amd64-uefi
	//
	//   - ipxe-arm64.efi for arm64-uefi
	//
	// required: true
	Loaders map[string]string
}

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

swagger:model

func (*BootEnv) AuthKey

func (b *BootEnv) AuthKey() string

func (*BootEnv) BootParamsFor

func (b *BootEnv) BootParamsFor(arch string) string

func (*BootEnv) CanHaveActions

func (b *BootEnv) CanHaveActions() bool

func (*BootEnv) Fill

func (b *BootEnv) Fill()

func (*BootEnv) GetDescription added in v4.1.0

func (b *BootEnv) GetDescription() string

func (*BootEnv) GetDocumentation

func (b *BootEnv) GetDocumentation() string

func (*BootEnv) GetMeta

func (b *BootEnv) GetMeta() Meta

func (*BootEnv) InitrdsFor

func (b *BootEnv) InitrdsFor(arch string) []string

func (*BootEnv) IsoFor

func (b *BootEnv) IsoFor(arch string) string

IsoFor is a helper function used by the backend to locate the ISO file that should be expanded to provide the install tree required for the bootenv to function.

func (*BootEnv) IsoUrlFor

func (b *BootEnv) IsoUrlFor(arch string) string

IsoUrlFor is a helper to return the upstream URL that the ISO for the BootEnv can be downloaded from. This generally points to a mirror location on the public Internet if one exists.

func (*BootEnv) KernelFor

func (b *BootEnv) KernelFor(arch string) string

func (*BootEnv) Key

func (b *BootEnv) Key() string

func (*BootEnv) KeyName

func (b *BootEnv) KeyName() string

func (*BootEnv) NetBoot

func (b *BootEnv) NetBoot() bool

NetBoot returns whether this bootenv is able to boot via PXE or some other network mechanism.

func (*BootEnv) Prefix

func (b *BootEnv) Prefix() string

func (*BootEnv) SetMeta

func (b *BootEnv) SetMeta(d Meta)

func (*BootEnv) SetName

func (b *BootEnv) SetName(n string)

func (*BootEnv) ShaFor

func (b *BootEnv) ShaFor(arch string) string

ShaFor is a helper to return the right SHA256 sum for the ISO that provides files for the BootEnv.

func (*BootEnv) SliceOf

func (b *BootEnv) SliceOf() interface{}

func (*BootEnv) ToModels

func (b *BootEnv) ToModels(obj interface{}) []Model

func (*BootEnv) Validate

func (b *BootEnv) Validate()

type BootEnver

type BootEnver interface {
	Model
	GetBootEnv() string
	SetBootEnv(string)
}

BootEnver interface defines if the model has a boot env

type BsdpBootOption

type BsdpBootOption struct {
	Index     uint16 `plist:"Index"`
	Install   bool   `plist:"IsInstall"`
	OSType    byte   `plist:"Kind"`
	OSVersion string `plist:"osVersion"`
	Name      string `plist:"Name"`
	Booter    string `plist:"BootFile"`
	RootPath  string `plist:"RootPath"`
}

BsdpBootOption contains the information needed to boot their systems using the aapl BDSP boot protocol. Unless you are provisioning Mac systems, you probably don't need to care about this.

func (*BsdpBootOption) InstallType

func (bo *BsdpBootOption) InstallType() string

func (*BsdpBootOption) MarshalText

func (bo *BsdpBootOption) MarshalText() ([]byte, error)

func (*BsdpBootOption) OSName

func (bo *BsdpBootOption) OSName() string

func (*BsdpBootOption) String

func (bo *BsdpBootOption) String() string

func (*BsdpBootOption) UnmarshalText

func (bo *BsdpBootOption) UnmarshalText(buf []byte) error

type Bundled

type Bundled struct {
	// Bundle tracks the name of the store containing this object
	// read only: true
	Bundle string
}

Bundle holds the object's store's name

swagger: model

func (*Bundled) GetBundle

func (b *Bundled) GetBundle() string

GetBundle gets the name of the content layer holding this object.

func (*Bundled) SetBundle

func (b *Bundled) SetBundle(name string)

SetBundle sets the name of the content layer holding this object.

type Bundler

type Bundler interface {
	SetBundle(string)
	GetBundle() string
}

type CatalogItem added in v4.0.3

type CatalogItem struct {
	Validation
	Access
	// Meta Items
	// Icon        string
	// Color       string
	// Author      string
	// DisplayName string
	// License     string
	// Copyright   string
	// CodeSource  string
	Meta

	Owned

	Id   string
	Type string

	Name          string
	ActualVersion string
	Version       string
	ContentType   string
	Source        string
	Shasum256     map[string]string
	NOJQSource    string

	Tip    bool
	HotFix bool
}

CatalogItem structure that handles RawModel instead of dealing with RawModel which is how DRP is storing it.

func (*CatalogItem) Clone added in v4.0.3

func (ci *CatalogItem) Clone() *CatalogItem

Clone the endpoint

func (*CatalogItem) DownloadUrl added in v4.0.3

func (ci *CatalogItem) DownloadUrl(arch, os string) string

DownloadUrl returns a URL that you can use to download the artifact for this catalog item. If the CatalogItem has a ContentType of `PluginProvider`, arch and os must be set appropriately for the target binary type, otherwise they can be left blank.

func (*CatalogItem) FileName added in v4.0.3

func (ci *CatalogItem) FileName() string

FileName returns the recommended filename to use when writing this catalog item to disk.

func (*CatalogItem) Fill added in v4.0.3

func (ci *CatalogItem) Fill()

func (*CatalogItem) Key added in v4.0.3

func (ci *CatalogItem) Key() string

func (*CatalogItem) KeyName added in v4.0.3

func (ci *CatalogItem) KeyName() string

func (*CatalogItem) Prefix added in v4.0.3

func (ci *CatalogItem) Prefix() string

type ChangeForcer

type ChangeForcer interface {
	ForceChange()
	ChangeForced() bool
}

type Claim

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. User is an API user of DigitalRebar Provision swagger:model

func (*Claim) Contains

func (a *Claim) Contains(b *Claim) bool

func (*Claim) Match

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.

func (*Claim) String

func (c *Claim) String() string

func (*Claim) Validate

func (c *Claim) Validate(e ErrorAdder)

type Claims

type Claims []claim

Claims is a compiled list of claims from a Role.

func (Claims) Contains

func (a Claims) Contains(b Claims) bool

Claims returns true if all of the claims in a are a superset of b

type ClaimsList

type ClaimsList []Claims

ClaimsList is a list of Claims derived from a Role.

func (ClaimsList) Match

func (c ClaimsList) Match(wanted Claims) bool

Match returns true if one of the entries in c contains wanted

type Content

type Content struct {
	// required: true
	Meta ContentMetaData `json:"meta"`

	/*
		These are the sections:
		tasks        map[string]*models.Task
		bootenvs     map[string]*models.BootEnv
		stages       map[string]*models.Stage
		templates    map[string]*models.Template
		profiles     map[string]*models.Profile
		params       map[string]*models.Param
		reservations map[string]*models.Reservation
		subnets      map[string]*models.Subnet
		users        map[string]*models.User
		preferences  map[string]*models.Pref
		plugins      map[string]*models.Plugin
		machines     map[string]*models.Machine
		leases       map[string]*models.Lease
	*/
	Sections Sections `json:"sections"`
}

Content models a content bundle. It consists of the metadata describing the content bundle and the objects that the content bundle provides. Upon being sucessfully loaded into dr-provision, these objects will be present and immutable until the content bundle is removed or replaced.

swagger:model

func (*Content) AuthKey

func (c *Content) AuthKey() string

func (*Content) Fill

func (c *Content) Fill()

func (*Content) FromStore

func (c *Content) FromStore(src store.Store) error

FromStore loads the contents of a Store into a content bundle.

func (*Content) GenerateMetaMap

func (c *Content) GenerateMetaMap() map[string]string

func (*Content) GetDescription added in v4.1.0

func (c *Content) GetDescription() string

func (*Content) GetDocumentation added in v4.1.0

func (c *Content) GetDocumentation() string

func (*Content) Key

func (c *Content) Key() string

func (*Content) KeyName

func (c *Content) KeyName() string

func (*Content) Mangle

func (c *Content) Mangle(thunk func(string, interface{}) (interface{}, error)) error

func (*Content) Prefix

func (c *Content) Prefix() string

func (*Content) ToStore

func (c *Content) ToStore(dest store.Store) error

ToStore saves a Content bundle into a format that can be used but the stackable store system dr-provision uses to save its working data.

type ContentMetaData

type ContentMetaData struct {
	// Name is the name of the content bundle.  Name must be unique across
	// all content bundles loaded into a given dr-provision instance.
	// required: true
	Name string
	// Version is a Semver-compliant string describing the version of
	// the content as a whole.  If left empty, the version is assumed to
	// be 0.0.0
	Version string
	// Description is a one or two line description of what the content
	// bundle provides.
	Description string
	// Source is mostly deprecated, replaced by Author and CodeSource.
	// It can be left blank.
	Source string

	// Documentation should contain Sphinx RST formatted documentation
	// for the content bundle describing its usage.
	Documentation string
	// RequiredFeatures is a comma-seperated list of features that
	// dr-provision must provide for the content bundle to operate properly.
	// These correspond to the Features field in the Info struct.
	RequiredFeatures string
	// Prerequisites is also a comma-seperated list that contains other
	// (possibly version-qualified) content bundles that must be present
	// for this content bundle to load into dr-provision.  Each entry in
	// the Prerequisites list should be in for format of name: version
	// constraints.  The colon and the version constraints may be
	// omitted if there are no version restrictions on the required
	// content bundle.
	//
	// See ../doc/arch/content-package.rst for more detailed info.
	Prerequisites string

	// New descriptor fields for catalog.  These are used by the UX.
	Color       string
	Icon        string
	Author      string
	DisplayName string
	License     string
	Copyright   string
	CodeSource  string
	Order       string
	Tags        string // Comma separated list
	DocUrl      string

	// Informational Fields
	Type         string
	Writable     bool
	Overwritable bool
}

ContentMetaData holds all the metadata about a content bundle that dr-provision will use to decide how to treat the content bundle.

All fields must be strings All string fields will be trimmed except Documentation.

type ContentSummary

type ContentSummary struct {
	Meta     ContentMetaData `json:"meta"`
	Counts   map[string]int
	Warnings []string
}

swagger:model

func (*ContentSummary) Fill

func (c *ContentSummary) Fill()

func (*ContentSummary) FromStore

func (c *ContentSummary) FromStore(src store.Store)

type Context added in v4.0.21

type Context struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of this Context.
	Name string
	// Image the OS image that jobs will execute in when running in this Context.
	// This is usually a Docker container, a VM image, or something similar.
	Image string
	// Engine is the system that runs the Image.  This is something like
	// docker, kubernetes, AWS, or something similar.
	Engine        string
	Description   string
	Documentation string
}

func (*Context) AuthKey added in v4.0.21

func (c *Context) AuthKey() string

func (*Context) Fill added in v4.0.21

func (c *Context) Fill()

func (*Context) GetMeta added in v4.0.21

func (c *Context) GetMeta() Meta

func (*Context) Key added in v4.0.21

func (c *Context) Key() string

func (*Context) KeyName added in v4.0.21

func (c *Context) KeyName() string

func (*Context) Prefix added in v4.0.21

func (c *Context) Prefix() string

func (*Context) SetMeta added in v4.0.21

func (c *Context) SetMeta(d Meta)

func (*Context) SliceOf added in v4.0.21

func (c *Context) SliceOf() interface{}

func (*Context) ToModels added in v4.0.21

func (c *Context) ToModels(obj interface{}) []Model

type Descer added in v4.1.0

type Descer interface {
	Model
	GetDescription() string
}

Descer interface defines if the object has a description field

type DhcpOption

type DhcpOption struct {
	// Code is a DHCP Option Code.
	//
	// required: true
	Code byte
	// Value is a text/template that will be expanded
	// and then converted into the proper format
	// for the option code
	//
	// required: true
	Value string
}

DhcpOption is a representation of a specific DHCP option. swagger:model

func DHCPOptionsInOrder

func DHCPOptionsInOrder(p dhcp.Packet) (res []*DhcpOption, err error)

DHCPOptionsInOrder returns the DHCP options present in the passed-in Packet in the order they appeared, excluding the Pad and End options.

func (*DhcpOption) AddToPacket

func (o *DhcpOption) AddToPacket(p *dhcp.Packet) error

func (*DhcpOption) ConvertOptionValueToByte

func (o *DhcpOption) ConvertOptionValueToByte(value string) ([]byte, error)

func (*DhcpOption) Fill

func (o *DhcpOption) Fill(s string) error

func (*DhcpOption) FillFromPacketOpt

func (o *DhcpOption) FillFromPacketOpt(buf []byte)

func (DhcpOption) RenderToDHCP

func (o DhcpOption) RenderToDHCP(srcOpts map[int]string) (code byte, val []byte, err error)

func (*DhcpOption) String

func (o *DhcpOption) String() string

type Docer

type Docer interface {
	Model
	GetDocumentation() string
}

Docer interface defines if the object has a documentation field

type Error

type Error struct {
	Object Model `json:"-"`
	Model  string
	Key    string
	Type   string
	// Messages are any additional messages related to this Error
	Messages []string
	// code is the HTTP status code that should be used for this Error
	Code int
}

Error is the common Error type the API returns for any error conditions.

swagger:model

func NewError

func NewError(t string, code int, m string) *Error

NewError creates a new Error with a few key parameters pre-populated.

func (*Error) AddError

func (e *Error) AddError(src error)

func (*Error) ContainsError

func (e *Error) ContainsError() bool

func (*Error) Error

func (e *Error) Error() string

Error satifies the global error interface.

func (*Error) Errorf

func (e *Error) Errorf(s string, args ...interface{})

Errorf appends a new error message into the Messages tracked by the Error.

func (*Error) HasError

func (e *Error) HasError() error

type ErrorAdder

type ErrorAdder interface {
	Errorf(string, ...interface{})
	AddError(error)
	HasError() error
}

ErrorAdder is an interface that the various models that can collect errors for later repoting can satisfy.

type Event

type Event struct {
	// Time of the event.
	// swagger:strfmt date-time
	Time time.Time

	// Type - object type
	Type string

	// Action - what happened
	Action string

	// Key - the id of the object
	Key string

	// Principal - the user or subsystem that caused the event to be emitted
	Principal string

	// Object - the data of the object.
	Object interface{}

	// Original - the data of the object before the operation (update and save only)
	Original interface{}
}

Event represents an action in the system. In general, the event generates for a subject of the form: type.action.key

swagger:model

func EventFor

func EventFor(obj Model, action string) *Event

func (*Event) Message

func (e *Event) Message() string

func (*Event) Model

func (e *Event) Model() (Model, error)

func (*Event) Text

func (e *Event) Text() string

type Filler

type Filler interface {
	Model
	Fill()
}

Filler interface defines if a model can be filled/initialized

type HaPassiveState added in v4.3.0

type HaPassiveState struct {
	// required: true
	Id string `json:"id"`
	// required: true
	Address string `json:"address"`
	// required: true
	State string `json:"state"`
}

HaPassiveState the state of the passive node

swagger:model

type Index

type Index struct {
	// Type gives you a rough idea of how the string used to query
	// this index should be formatted.
	Type string
	// Unique tells you whether there can be mutiple entries in the
	// index for the same key that refer to different items.
	Unique bool
	// Unordered tells you whether this index cannot be sorted.
	Unordered bool
	// Regex indecates whether you can use the Re filter with this index
	Regex bool
}

Index holds details on the index swagger:model

type Info

type Info struct {
	// required: true
	Arch string `json:"arch"`
	// required: true
	Os string `json:"os"`
	// required: true
	Version string `json:"version"`
	// required: true
	Id string `json:"id"`
	// required: true
	LocalId string `json:"local_id"`
	// required: true
	HaId string `json:"ha_id"`
	// required: true
	ApiPort int `json:"api_port"`
	// required: true
	FilePort int `json:"file_port"`
	// required: true
	DhcpPort int `json:"dhcp_port"`
	// required: true
	BinlPort int `json:"binl_port"`
	// required: true
	TftpPort int `json:"tftp_port"`
	// required: true
	TftpEnabled bool `json:"tftp_enabled"`
	// required: true
	DhcpEnabled bool `json:"dhcp_enabled"`
	// required: true
	BinlEnabled bool `json:"binl_enabled"`
	// required: true
	ProvisionerEnabled bool `json:"prov_enabled"`
	// required: true
	Address net.IP `json:"address"`
	// required: true
	Stats    []Stat                         `json:"stats"`
	Features []string                       `json:"features"`
	Scopes   map[string]map[string]struct{} `json:"scopes"`
	License  LicenseBundle

	// Errors returns the current system errors.
	// required: true
	Errors []string `json:"errors"`

	// HaEnabled indicates if High Availability is enabled
	HaEnabled bool `json:"ha_enabled"`
	// HaVirtualAddress is the Virtual IP Address of the systems
	HaVirtualAddress string `json:"ha_virtual_address"`
	// HaIsActive indicates Active (true) or Passive (false)
	// required: true
	HaIsActive bool `json:"ha_is_active"`
	// HaStatus indicates current state
	// For Active, Up is the only value.
	// For Passive, Connecting, Syncing, In-Sync
	// required: true
	HaStatus string `json:"ha_status"`

	// HaActiveId is the id of current active node
	HaActiveId string `json:"ha_active_id"`
	// HaPassiveState is a list of passive node's and their current state
	// This is only valid from the Active node
	HaPassiveState []*HaPassiveState `json:"ha_passive_state"`
}

Info contains information on how the running instance of dr-provision is configured.

For passive nodes, the license, scopes, and stats are not filled in.

swagger:model

func (*Info) AddUpdatePassive added in v4.3.0

func (i *Info) AddUpdatePassive(id, address, state string)

func (*Info) Fill

func (i *Info) Fill()

func (*Info) HasFeature

func (i *Info) HasFeature(f string) bool

HasFeature is a helper function to determine if a requested feature is present.

func (*Info) RemovePassive added in v4.3.0

func (i *Info) RemovePassive(id string)

type Interface

type Interface struct {
	Access
	Meta
	// Name of the interface
	//
	// required: true
	Name string
	// Index of the interface
	//
	Index int
	// A List of Addresses on the interface (CIDR)
	//
	// required: true
	Addresses []string
	// The interface to use for this interface when
	// advertising or claiming access (CIDR)
	//
	ActiveAddress string
	// Possible gateway for this interface
	Gateway string
	// Possible DNS for this interface
	DnsServers []string
	// Possible DNS for domain for this interface
	DnsDomain string
}

Interface represents a network interface that is present on the server running dr-provision. It is primarily used by the UX to help generate Subnets.

swagger:model

func (*Interface) Fill

func (i *Interface) Fill()

func (*Interface) Key

func (i *Interface) Key() string

func (*Interface) KeyName

func (i *Interface) KeyName() string

func (*Interface) Prefix

func (i *Interface) Prefix() string

func (*Interface) SliceOf

func (b *Interface) SliceOf() interface{}

func (*Interface) ToModels

func (b *Interface) ToModels(obj interface{}) []Model

type Job

type Job struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// The UUID of the job.  The primary key.
	// required: true
	// swagger:strfmt uuid
	Uuid uuid.UUID
	// The UUID of the previous job to run on this machine.
	// swagger:strfmt uuid
	Previous uuid.UUID
	// The machine the job was created for.  This field must be the UUID of the machine.
	// required: true
	// swagger:strfmt uuid
	Machine uuid.UUID
	// The task the job was created for.  This will be the name of the task.
	// read only: true
	Task string
	// The stage that the task was created in.
	// read only: true
	Stage string
	// Context is the context the job was created to run in.
	Context string
	// The state the job is in.  Must be one of "created", "running", "failed", "finished", "incomplete"
	// required: true
	State string
	// The final disposition of the job.
	// Can be one of "reboot","poweroff","stop", or "complete"
	// Other substates may be added as time goes on
	ExitState string
	// The time the job started running.
	StartTime time.Time
	// The time the job failed or finished.
	EndTime time.Time
	// Archived indicates whether the complete log for the job can be
	// retrieved via the API.  If Archived is true, then the log cannot
	// be retrieved.
	//
	// required: true
	Archived bool
	// Whether the job is the "current one" for the machine or if it has been superceded.
	//
	// required: true
	Current bool
	// The current index is the machine CurrentTask that created this job.
	//
	// required: true
	// read only: true
	CurrentIndex int
	// The next task index that should be run when this job finishes.  It is used
	// in conjunction with the machine CurrentTask to implement the server side of the
	// machine agent state machine.
	//
	// required: true
	// read only: true
	NextIndex int
	// The workflow that the task was created in.
	// read only: true
	Workflow string
	// The bootenv that the task was created in.
	// read only: true
	BootEnv string
	// ExtraClaims is the expanded list of extra Claims that were added to the
	// default machine Claims via the ExtraRoles field on the Task that the Job
	// was created to run.
	ExtraClaims []*Claim `json:"ExtraClaims,omitempty"`
	// Token is the JWT token that should be used when running this Job.  If not
	// present or empty, the Agent running the Job will use its ambient Token
	// instead.  If set, the Token will only be valid for the current Job.
	Token string `json:"Token, omitempty"`
}

Job contains information on a Job that is running for a specific Task on a Machine.

swagger:model

func (*Job) AuthKey

func (j *Job) AuthKey() string

func (*Job) CanHaveActions

func (b *Job) CanHaveActions() bool

func (*Job) Fill

func (j *Job) Fill()

func (*Job) GetMeta

func (j *Job) GetMeta() Meta

func (*Job) Key

func (j *Job) Key() string

func (*Job) KeyName

func (j *Job) KeyName() string

func (*Job) Prefix

func (j *Job) Prefix() string

func (*Job) SetMeta

func (j *Job) SetMeta(d Meta)

func (*Job) SliceOf

func (b *Job) SliceOf() interface{}

func (*Job) ToModels

func (b *Job) ToModels(obj interface{}) []Model

func (*Job) Validate

func (j *Job) Validate()

type JobAction

type JobAction struct {
	// required: true
	Name string
	// required: true
	Path string
	// required: true
	Content string
	// required: true
	Meta map[string]string
}

Job Action is something that job runner will need to do. If path is specified, then the runner will place the contents into that location. If path is not specified, then the runner will attempt to bash exec the contents. swagger:model

func (*JobAction) ValidForOS

func (ja *JobAction) ValidForOS(target string) bool

type JobActions

type JobActions []*JobAction

func (JobActions) FilterOS

func (ja JobActions) FilterOS(forOS string) JobActions

type Lease

type Lease struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Addr is the IP address that the lease handed out.
	//
	// required: true
	// swagger:strfmt ipv4
	Addr net.IP
	// NextServer is the IP address that we should have the machine talk to
	// next.  In most cases, this will be our address.
	//
	// required: false
	// swagger:strfmt ipv4
	NextServer net.IP
	// Via is the IP address used to select which subnet the lease belongs to.
	// It is either an address present on a local interface that dr-provision is
	// listening on, or the GIADDR field of the DHCP request.
	//
	// required: false
	// swagger:strfmt ipv4
	Via net.IP
	// Token is the unique token for this lease based on the
	// Strategy this lease used.
	//
	// required: true
	Token string
	// Duration is the time in seconds for which a lease can be valid.
	// ExpireTime is calculated from Duration.
	Duration int32
	// ExpireTime is the time at which the lease expires and is no
	// longer valid The DHCP renewal time will be half this, and the
	// DHCP rebind time will be three quarters of this.
	//
	// required: true
	// swagger:strfmt date-time
	ExpireTime time.Time
	// Strategy is the leasing strategy that will be used determine what to use from
	// the DHCP packet to handle lease management.
	//
	// required: true
	Strategy string
	// State is the current state of the lease.  This field is for informational
	// purposes only.
	//
	// read only: true
	// required: true
	State string
	// Options are the DHCP options that the Lease is running with.
	Options []DhcpOption
	// ProvidedOptions are the DHCP options the last Discover or Offer packet
	// for this lease provided to us.
	ProvidedOptions []DhcpOption
	// SkipBoot indicates that the DHCP system is allowed to offer
	// boot options for whatever boot protocol the machine wants to
	// use.
	//
	// read only: true
	SkipBoot bool
}

Lease tracks DHCP leases. swagger:model

func (*Lease) AuthKey

func (l *Lease) AuthKey() string

func (*Lease) CanHaveActions

func (b *Lease) CanHaveActions() bool

func (*Lease) Expire

func (l *Lease) Expire()

func (*Lease) Expired

func (l *Lease) Expired() bool

func (*Lease) Fake

func (l *Lease) Fake() bool

func (*Lease) Fill

func (l *Lease) Fill()

func (*Lease) GetMeta

func (l *Lease) GetMeta() Meta

func (*Lease) Invalidate

func (l *Lease) Invalidate()

func (*Lease) Key

func (l *Lease) Key() string

func (*Lease) KeyName

func (l *Lease) KeyName() string

func (*Lease) Prefix

func (l *Lease) Prefix() string

func (*Lease) SetMeta

func (l *Lease) SetMeta(d Meta)

func (*Lease) SliceOf

func (b *Lease) SliceOf() interface{}

func (*Lease) String

func (l *Lease) String() string

func (*Lease) ToModels

func (b *Lease) ToModels(obj interface{}) []Model

type License

type License struct {
	Name            string
	Version         string
	Data            interface{}
	PurchaseDate    time.Time
	StartDate       time.Time
	SoftExpireDate  time.Time
	HardExpireDate  time.Time
	ShortLicense    string
	LongLicense     string
	Active, Expired bool
}

License is used to authorize acess to extended dr-provision features and functionality.

func (*License) Check

func (l *License) Check(ref time.Time) (active, expired bool)

type LicenseBundle

type LicenseBundle struct {
	Contact           string
	ContactEmail      string
	ContactId         string
	Owner             string
	OwnerEmail        string
	OwnerId           string
	Grantor           string
	GrantorEmail      string
	Version           string
	GenerationVersion string
	Endpoints         []string `json:",omitempty"`
	// MaxDrpVersion is the highest major/minor version to allow.
	// For example, v4.3 would mean any v4.3.* release or previous.
	MaxDrpVersion string

	Licenses []License
}

LicenseBundle is a collection of Licenses.

type Machine

type Machine struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Partialed
	// The name of the machine.  This must be unique across all
	// machines, and by convention it is the FQDN of the machine,
	// although nothing enforces that.
	//
	// required: true
	// swagger:strfmt hostname
	Name string
	// A description of this machine.  This can contain any reference
	// information for humans you want associated with the machine.
	Description string
	// The UUID of the machine.
	// This is auto-created at Create time, and cannot change afterwards.
	//
	// required: true
	// swagger:strfmt uuid
	Uuid uuid.UUID
	// The UUID of the job that is currently running on the machine.
	//
	// swagger:strfmt uuid
	CurrentJob uuid.UUID
	// The IPv4 address of the machine that should be used for PXE
	// purposes.  Note that this field does not directly tie into DHCP
	// leases or reservations -- the provisioner relies solely on this
	// address when determining what to render for a specific machine.
	// Address is updated automatically by the DHCP system if
	// HardwareAddrs is filled out.
	//
	// swagger:strfmt ipv4
	Address net.IP
	// The stage that the Machine is currently in.  If Workflow is also
	// set, this field is read-only, otherwise changing it will change
	// the Stage the system is in.
	Stage string
	// The boot environment that the machine should boot into.  This
	// must be the name of a boot environment present in the backend.
	// If this field is not present or blank, the global default bootenv
	// will be used instead.
	BootEnv string
	// An array of profiles to apply to this machine in order when looking
	// for a parameter during rendering.
	Profiles []string
	// The Parameters that have been directly set on the Machine.
	Params map[string]interface{}
	// The tasks this machine has to run.
	Tasks []string
	// The index into the Tasks list for the task that is currently
	// running (if a task is running) or the next task that will run (if
	// no task is currently running).  If -1, then the first task will
	// run next, and if it is equal to the length of the Tasks list then
	// all the tasks have finished running.
	//
	// required: true
	CurrentTask int
	// Indicates if the machine can run jobs or not.  Failed jobs mark the machine
	// not runnable.
	//
	// required: true
	Runnable bool
	// Secret for machine token revocation.  Changing the secret will invalidate
	// all existing tokens for this machine
	Secret string
	// OS is the operating system that the node is running in.  It is updated by Sledgehammer and by
	// the various OS install tasks.
	//
	OS string
	// HardwareAddrs is a list of MAC addresses we expect that the system might boot from.
	// This must be filled out to enable MAC address based booting from the various bootenvs,
	// and must be updated if the MAC addresses for a system change for whatever reason.
	//
	HardwareAddrs []string
	// Workflow is the workflow that is currently responsible for processing machine tasks.
	//
	// required: true
	Workflow string
	// Arch is the machine architecture. It should be an arch that can
	// be fed into $GOARCH.
	//
	// required: true
	Arch string
	// Locked indicates that changes to the Machine by users are not
	// allowed, except for unlocking the machine, which will always
	// generate an Audit event.
	//
	// required: true
	Locked bool
	// Contexts contains the name of the current execution context for the machine.
	// An empty string indicates that the agent running on the machine should be executing tasks,
	// and any other value means that an agent running with its context set for this value should
	// be executing tasks.
	Context string
	// Fingerprint is a collection of data that can (in theory) be used to uniquely identify
	// a machine based on various DMI information.  This (in conjunction with HardwareAddrs)
	// is used to uniquely identify a Machine using a score based on how many total items in the Fingerprint
	// match.
	Fingerprint MachineFingerprint
}

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

func (*Machine) AddTasks

func (b *Machine) AddTasks(offset int, tasks ...string) error

AddTasks is a helper for adding tasks to the machine Tasks list in the mutable present.

func (*Machine) AuthKey

func (n *Machine) AuthKey() string

func (*Machine) CanHaveActions

func (b *Machine) CanHaveActions() bool

func (*Machine) DelTasks

func (b *Machine) DelTasks(tasks ...string)

DelTasks allows you to delete tasks in the mutable present.

func (*Machine) Fill

func (n *Machine) Fill()

func (*Machine) GetBootEnv

func (b *Machine) GetBootEnv() string

match BootEnver interface

func (*Machine) GetDescription added in v4.1.0

func (m *Machine) GetDescription() string

func (*Machine) GetMeta

func (n *Machine) GetMeta() Meta

func (*Machine) GetParams

func (b *Machine) GetParams() map[string]interface{}

match Param interface

func (*Machine) GetProfiles

func (b *Machine) GetProfiles() []string

match Profiler interface

func (*Machine) GetTasks

func (b *Machine) GetTasks() []string

match TaskRunner interface

func (*Machine) IsLocked

func (n *Machine) IsLocked() bool

func (*Machine) Key

func (n *Machine) Key() string

func (*Machine) KeyName

func (n *Machine) KeyName() string

func (*Machine) Prefix

func (n *Machine) Prefix() string

func (*Machine) RunningTask

func (b *Machine) RunningTask() int

func (*Machine) SetBootEnv

func (b *Machine) SetBootEnv(s string)

func (*Machine) SetMeta

func (n *Machine) SetMeta(d Meta)

func (*Machine) SetName

func (b *Machine) SetName(n string)

func (*Machine) SetParams

func (b *Machine) SetParams(p map[string]interface{})

func (*Machine) SetProfiles

func (b *Machine) SetProfiles(p []string)

func (*Machine) SetTasks

func (b *Machine) SetTasks(t []string)

func (*Machine) SliceOf

func (b *Machine) SliceOf() interface{}

func (*Machine) SplitTasks

func (b *Machine) SplitTasks() (thePast []string, thePresent []string, theFuture []string)

SplitTasks slits the machine's Tasks list into 3 subsets:

1. the immutable past, which cannot be chnaged by task list modification

2. The mutable present, which contains tasks that can be deleted, and where tasks can be added.

3. The immutable future, which also cannot be changed.

func (*Machine) ToModels

func (b *Machine) ToModels(obj interface{}) []Model

func (*Machine) UUID

func (n *Machine) UUID() string

func (*Machine) Validate

func (n *Machine) Validate()

type MachineFingerprint added in v4.3.0

type MachineFingerprint struct {
	// DMI.System.Manufacturer + DMI.System.ProductName + DMI.System.SerialNumber, SHA256 hashed
	// Hash must not be zero-length to match. 25 points
	SSNHash []byte
	// DMI.System.Manufacturer + DMI.System.ProductName + DMI.Chassis[0].SerialNumber, SHA256 hashed
	// Hash must not be zero-length to match. 25 points
	CSNHash []byte
	// DMI.System.UUID, not hashed. Must be non zero length and must be a non-zero UUID. 50 point match
	SystemUUID string
	// MemoryIds is an array of SHA256sums if the following fields in each
	// entry of the DMI.Memory.Devices array concatenated together:
	//  * Manufacturer
	//  * PartNumber
	//  * SerialNumber
	// Each hash must not be zero length
	// Score is % matched.
	MemoryIds [][]byte
}

func (*MachineFingerprint) Fill added in v4.3.0

func (m *MachineFingerprint) Fill()

type Meta

type Meta map[string]string

Meta holds information about arbitrary things. Initial usage will be for UX elements.

swagger: model

func (Meta) AddFeature

func (m Meta) AddFeature(flag string)

func (Meta) ClearFeatures

func (m Meta) ClearFeatures()

func (Meta) Features

func (m Meta) Features() []string

func (Meta) HasFeature

func (m Meta) HasFeature(flag string) bool

func (Meta) MergeFeatures

func (m Meta) MergeFeatures(other []string)

func (Meta) RemoveFeature

func (m Meta) RemoveFeature(flag string)

type MetaHaver

type MetaHaver interface {
	Model
	GetMeta() Meta
	SetMeta(Meta)
}

type ModTimeSha added in v4.3.0

type ModTimeSha struct {
	ModTime time.Time
	ShaSum  []byte
}

func (*ModTimeSha) Generate added in v4.3.0

func (m *ModTimeSha) Generate(fi *os.File) error

func (*ModTimeSha) MarshalBinary added in v4.3.0

func (m *ModTimeSha) MarshalBinary() ([]byte, error)

func (*ModTimeSha) ReadFromXattr added in v4.3.0

func (m *ModTimeSha) ReadFromXattr(fi *os.File) error

func (*ModTimeSha) SaveToXattr added in v4.3.0

func (m *ModTimeSha) SaveToXattr(fi *os.File) error

func (*ModTimeSha) String added in v4.3.0

func (m *ModTimeSha) String() string

func (*ModTimeSha) UnmarshalBinary added in v4.3.0

func (m *ModTimeSha) UnmarshalBinary(buf []byte) error

func (*ModTimeSha) UpToDate added in v4.3.0

func (m *ModTimeSha) UpToDate(fi *os.File) bool

type Model

type Model interface {
	Prefix() string
	Key() string
	KeyName() string
}

Model is the interface that pretty much all non-Error objects returned by the API satisfy.

func All

func All() []Model

All returns a slice containing a single blank instance of all the Models.

func Clone

func Clone(m Model) Model

Clone returns a deep copy of the passed-in Model

type NameSetter

type NameSetter interface {
	Model
	SetName(string)
}

NameSetter interface if the model can change names

type OsInfo

type OsInfo struct {
	// The name of the OS this BootEnv has.  It should be formatted as
	// family-version.
	//
	// required: true
	Name string
	// The family of operating system (linux distro lineage, etc)
	Family string
	// The codename of the OS, if any.
	Codename string
	// The version of the OS, if any.
	Version string
	// The name of the ISO that the OS should install from.  If
	// non-empty, this is assumed to be for the amd64 hardware
	// architecture.
	IsoFile string
	// The SHA256 of the ISO file.  Used to check for corrupt downloads.
	// If non-empty, this is assumed to be for the amd64 hardware
	// architecture.
	IsoSha256 string
	// The URL that the ISO can be downloaded from, if any.  If
	// non-empty, this is assumed to be for the amd64 hardware
	// architecture.
	//
	// swagger:strfmt uri
	IsoUrl string
	// SupportedArchitectures maps from hardware architecture (named
	// according to the distro architecture naming scheme) to the
	// architecture-specific parameters for this OS.  If
	// SupportedArchitectures is left empty, then the system assumes
	// that the BootEnv only supports amd64 platforms.
	SupportedArchitectures map[string]ArchInfo
}

OsInfo holds information about the operating system this BootEnv maps to. Most of this information is optional for now. swagger:model

func (OsInfo) FamilyName

func (o OsInfo) FamilyName() string

FamilyName is a helper that figures out the family (read: distro name) of the OS. It uses Family if set, the first part of the Name otherwise.

func (OsInfo) FamilyType

func (o OsInfo) FamilyType() string

FamilyType figures out the lineage of the OS. If the OS is descended from RHEL, then "rhel" is returned. If the OS is descended from Debian, then "debian" is returned, otherwise FamilyName() is returned. Return values of this function are subject to change as support for new distros is brought onboard.

func (OsInfo) FamilyVersion

func (o OsInfo) FamilyVersion() string

FamilyVersion figures out the version of the OS. It returns the Version field if set, and the second part of the OS name if not set. This should be a Semver-ish version string, not a codename, release name, or similar item.

func (OsInfo) VersionEq

func (o OsInfo) VersionEq(other string) bool

VersionEq returns true of this OS version is equal to the degree of accuracy implied by other -- o.Version(7.3) is VersionEq to 7 and 7.3, but not 7.3.11

type Owned

type Owned struct {
	// Endpoint tracks the owner of the object amoung DRP endpoints
	// read only: true
	Endpoint string
}

Owned holds the info about which DRP Endpoint owns this object

swagger: model

func (*Owned) GetEndpoint

func (o *Owned) GetEndpoint() string

GetEndpoint returns the name of the owning DRP Endpoint

func (*Owned) SetEndpoint

func (o *Owned) SetEndpoint(n string)

SetEndpoint sets the model's Endpoint

type Owner

type Owner interface {
	GetEndpoint() string
	SetEndpoint(string)
}

model object may define a GetEndpoint() method that can be used to return the owner for the object

type Param

type Param struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of the param.  Params must be uniquely named.
	//
	// required: true
	Name string
	// Description is a one-line description of the parameter.
	Description string
	// Documentation details what the parameter does, what values it can
	// take, what it is used for, etc.
	Documentation string
	// Secure implies that any API interactions with this Param
	// will deal with SecureData values.
	//
	// required: true
	Secure bool
	// Schema must be a valid JSONSchema as of draft v4.
	//
	// required: true
	Schema interface{}
}

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

func (p *Param) AuthKey() string

func (*Param) DefaultValue

func (p *Param) DefaultValue() (interface{}, bool)

func (*Param) Fill

func (p *Param) Fill()

func (*Param) GetDescription added in v4.1.0

func (p *Param) GetDescription() string

func (*Param) GetDocumentation

func (p *Param) GetDocumentation() string

func (*Param) GetMeta

func (p *Param) GetMeta() Meta

func (*Param) Key

func (p *Param) Key() string

func (*Param) KeyName

func (p *Param) KeyName() string

func (*Param) Prefix

func (p *Param) Prefix() string

func (*Param) SetMeta

func (p *Param) SetMeta(d Meta)

func (*Param) SetName

func (p *Param) SetName(s string)

func (*Param) SliceOf

func (b *Param) SliceOf() interface{}

func (*Param) ToModels

func (b *Param) ToModels(obj interface{}) []Model

func (*Param) TypeValue

func (p *Param) TypeValue() (interface{}, bool)

func (*Param) Validate

func (p *Param) Validate()

type Paramer

type Paramer interface {
	Model
	GetParams() map[string]interface{}
	SetParams(map[string]interface{})
}

Paramer interface defines if the model has parameters

type Partialed

type Partialed struct {
	// Partial tracks if the object is not complete when returned.
	// read only: true
	Partial bool
}

Partialed holds if the object is partially filled in.

swagger: model

func (*Partialed) IsPartial

func (p *Partialed) IsPartial() bool

IsPartial returns whether the object is partially returned. This will be set if the object has been slimmed or partially returned.

func (*Partialed) SetPartial

func (p *Partialed) SetPartial()

type Partialer

type Partialer interface {
	IsPartial() bool
	SetPartial()
}

Partialer is an interface that objects that are partially returned.

type Plugin

type Plugin struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Partialed
	// The name of the plugin instance.  THis must be unique across all
	// plugins.
	//
	// required: true
	Name string
	// A description of this plugin.  This can contain any reference
	// information for humans you want associated with the plugin.
	Description string
	// Documentation of this plugin.  This should tell what
	// the plugin is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// Any additional parameters that may be needed to configure
	// the plugin.
	Params map[string]interface{}
	// The plugin provider for this plugin
	//
	// required: true
	Provider string
	// Error unrelated to the object validity, but the execution
	// of the plugin.
	PluginErrors []string
}

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

func (*Plugin) AuthKey

func (n *Plugin) AuthKey() string

func (*Plugin) CanHaveActions

func (p *Plugin) CanHaveActions() bool

func (*Plugin) Fill

func (n *Plugin) Fill()

func (*Plugin) GetDescription added in v4.1.0

func (p *Plugin) GetDescription() string

func (*Plugin) GetDocumentation

func (p *Plugin) GetDocumentation() string

func (*Plugin) GetMeta

func (p *Plugin) GetMeta() Meta

func (*Plugin) GetParams

func (p *Plugin) GetParams() map[string]interface{}

match Paramer interface

func (*Plugin) Key

func (n *Plugin) Key() string

func (*Plugin) KeyName

func (n *Plugin) KeyName() string

func (*Plugin) Prefix

func (n *Plugin) Prefix() string

func (*Plugin) SetMeta

func (p *Plugin) SetMeta(d Meta)

func (*Plugin) SetName

func (p *Plugin) SetName(s string)

func (*Plugin) SetParams

func (p *Plugin) SetParams(pl map[string]interface{})

func (*Plugin) SliceOf

func (p *Plugin) SliceOf() interface{}

func (*Plugin) ToModels

func (p *Plugin) ToModels(obj interface{}) []Model

func (*Plugin) Validate

func (p *Plugin) Validate()

type PluginProvider

type PluginProvider struct {
	Meta

	// Name is the unique name of the PluginProvider.
	// Each Plugin provider must have a unique Name.
	Name string

	// The version of the PluginProvider.  This is a semver compatible string.
	Version string

	// This is used to indicate what version the plugin is built for
	// This is effectively the API version of the protocol that
	// plugin providers use to communicate with dr-provision.
	// Right now, all plugin providers must set this to version 4,
	// which is the only supported protocol version.
	PluginVersion int

	// If AutoStart is true, a Plugin will be created for this
	// Provider at provider definition time, if one is not already present.
	AutoStart bool

	// HasPlugin is deprecated, plugin provider binaries should use a websocket
	// event stream instead.
	HasPublish bool

	// AvailableActions lists the actions that this PluginProvider
	// can take.
	AvailableActions []AvailableAction

	// RequiredParams and OptionalParams
	// are Params that must be present on a Plugin for the Provider
	// to operate.
	RequiredParams []string
	OptionalParams []string

	// Object prefixes that can be accessed by this plugin.
	// The interface can be empty struct{} or a JSONSchema draft v4
	// This allows PluginProviders to define custom Object types that dr-provision will
	// store and check the validity of.
	StoreObjects map[string]interface{}

	// Documentation of this plugin provider.  This should tell what
	// the plugin provider is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string

	// Content Bundle Yaml string - can be optional or empty
	Content string
}

Plugin Provider describes the available functions that could be instantiated by a plugin. swagger:model

func (*PluginProvider) AutoPlugin

func (p *PluginProvider) AutoPlugin() *Plugin

AutoPlugin - builds a plugin model if auto start is true, otherwise nil

func (*PluginProvider) Fill

func (p *PluginProvider) Fill()

func (*PluginProvider) GetDocumentation

func (p *PluginProvider) GetDocumentation() string

func (*PluginProvider) GetMeta

func (p *PluginProvider) GetMeta() Meta

func (*PluginProvider) Key

func (p *PluginProvider) Key() string

func (*PluginProvider) KeyName

func (p *PluginProvider) KeyName() string

func (*PluginProvider) Prefix

func (p *PluginProvider) Prefix() string

func (*PluginProvider) SetMeta

func (p *PluginProvider) SetMeta(d Meta)

func (*PluginProvider) SliceOf

func (p *PluginProvider) SliceOf() interface{}

func (*PluginProvider) Store

func (p *PluginProvider) Store() (store.Store, error)

Store extracts the content bundle in the Content field of the PluginProvider into a Store.

func (*PluginProvider) ToModels

func (p *PluginProvider) ToModels(obj interface{}) []Model

type PluginProviderUploadInfo

type PluginProviderUploadInfo struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
}

swagger:model

type Pref

type Pref struct {
	Meta
	Name string
	Val  string
}

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 (*Pref) AuthKey

func (p *Pref) AuthKey() string

func (*Pref) Fill

func (p *Pref) Fill()

func (*Pref) Key

func (p *Pref) Key() string

func (*Pref) KeyName

func (p *Pref) KeyName() string

func (*Pref) Prefix

func (p *Pref) Prefix() string

func (*Pref) SliceOf

func (b *Pref) SliceOf() interface{}

func (*Pref) ToModels

func (b *Pref) ToModels(obj interface{}) []Model

type Profile

type Profile struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Partialed
	// The name of the profile.  This must be unique across all
	// profiles.
	//
	// required: true
	Name string
	// A description of this profile.  This can contain any reference
	// information for humans you want associated with the profile.
	Description string
	// Documentation of this profile.  This should tell what
	// the profile is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// Any additional parameters that may be needed to expand templates
	// for BootEnv, as documented by that boot environment's
	// RequiredParams and OptionalParams.
	Params map[string]interface{}
	// Additional Profiles that should be considered for parameters
	Profiles []string
}

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 (*Profile) AuthKey

func (p *Profile) AuthKey() string

AuthKey returns the value that should be validated against claims

func (*Profile) CanHaveActions

func (p *Profile) CanHaveActions() bool

CanHaveActions indicates if the object is allowed to have actions

func (*Profile) Fill

func (p *Profile) Fill()

Fill initializes the object

func (*Profile) GetDescription added in v4.1.0

func (p *Profile) GetDescription() string

GetDescription returns the object's description

func (*Profile) GetDocumentation added in v4.1.0

func (p *Profile) GetDocumentation() string

GetDocumentation returns the object's documentation

func (*Profile) GetMeta

func (p *Profile) GetMeta() Meta

GetMeta returns the meta data for this profile

func (*Profile) GetParams

func (p *Profile) GetParams() map[string]interface{}

GetParams returns the current parameters for this profile matches Paramer interface

func (*Profile) GetProfiles added in v4.0.18

func (p *Profile) GetProfiles() []string

GetProfiles returns the profiles on this profile

func (*Profile) Key

func (p *Profile) Key() string

Key returns the primary index for this object

func (*Profile) KeyName

func (p *Profile) KeyName() string

KeyName returns the field of the object that is used as the primary key

func (*Profile) Prefix

func (p *Profile) Prefix() string

Prefix returns the object type

func (*Profile) SetMeta

func (p *Profile) SetMeta(d Meta)

SetMeta sets the meta data for this profile

func (*Profile) SetName

func (p *Profile) SetName(n string)

SetName changes the name of the profile

func (*Profile) SetParams

func (p *Profile) SetParams(pl map[string]interface{})

SetParams sets the current parameters for this profile matches Paramer interface

func (*Profile) SetProfiles added in v4.0.18

func (p *Profile) SetProfiles(np []string)

SetProfiles sets the profiles on this profile

func (*Profile) SliceOf

func (p *Profile) SliceOf() interface{}

SliceOf returns an empty slice of this type of objects

func (*Profile) ToModels

func (p *Profile) ToModels(obj interface{}) []Model

ToModels converts a slice of these specific objects to a slice of Model interfaces

func (*Profile) Validate

func (p *Profile) Validate()

Validate makes sure that the object is valid (outside of references)

type Profiler

type Profiler interface {
	Model
	GetProfiles() []string
	SetProfiles([]string)
}

Profiler interface defines if the model has profiles

type RawModel

type RawModel map[string]interface{}

RawModel is a raw model that Plugins can specialize to save custom data in the dr-provision backing store.

func (*RawModel) AddError

func (r *RawModel) AddError(err error)

func (*RawModel) AuthKey

func (r *RawModel) AuthKey() string

func (*RawModel) CanHaveActions

func (r *RawModel) CanHaveActions() bool

func (*RawModel) ChangeForced

func (r *RawModel) ChangeForced() bool

func (*RawModel) ClearValidation

func (r *RawModel) ClearValidation()

func (*RawModel) Error

func (r *RawModel) Error() string

func (*RawModel) Errorf

func (r *RawModel) Errorf(fmtStr string, args ...interface{})

func (*RawModel) Fill

func (r *RawModel) Fill()

func (*RawModel) ForceChange

func (r *RawModel) ForceChange()

func (*RawModel) GetEndpoint

func (r *RawModel) GetEndpoint() string

Owner Interface

func (*RawModel) GetMeta

func (r *RawModel) GetMeta() Meta

MetaHaver Interface

func (*RawModel) GetParams

func (r *RawModel) GetParams() map[string]interface{}

match Paramer interface

func (*RawModel) GetStringField

func (r *RawModel) GetStringField(field string) (string, bool)

Helpers to get fields

func (*RawModel) HasError

func (r *RawModel) HasError() error

func (*RawModel) IsAvailable

func (r *RawModel) IsAvailable() bool

func (*RawModel) IsPartial

func (r *RawModel) IsPartial() bool

func (*RawModel) IsReadOnly

func (r *RawModel) IsReadOnly() bool

Access Interface

func (*RawModel) Key

func (r *RawModel) Key() string

func (*RawModel) KeyName

func (r *RawModel) KeyName() string

func (*RawModel) MakeError

func (r *RawModel) MakeError(code int, errType string, obj Model) error

func (*RawModel) Prefix

func (r *RawModel) Prefix() string

func (*RawModel) RestoreValidation

func (r *RawModel) RestoreValidation(or *RawModel)

func (*RawModel) SaveValidation

func (r *RawModel) SaveValidation() *Validation

Validator Interface

func (*RawModel) SetAvailable

func (r *RawModel) SetAvailable() bool

func (*RawModel) SetBundle

func (r *RawModel) SetBundle(name string)

func (*RawModel) SetEndpoint

func (r *RawModel) SetEndpoint(n string)

func (*RawModel) SetInvalid

func (r *RawModel) SetInvalid() bool

func (*RawModel) SetMeta

func (r *RawModel) SetMeta(d Meta)

func (*RawModel) SetParams

func (r *RawModel) SetParams(p map[string]interface{})

func (*RawModel) SetPartial

func (r *RawModel) SetPartial()

func (*RawModel) SetValid

func (r *RawModel) SetValid() bool

func (*RawModel) SliceOf

func (r *RawModel) SliceOf() interface{}

func (*RawModel) String

func (r *RawModel) String() string

func (*RawModel) ToModels

func (r *RawModel) ToModels(obj interface{}) []Model

func (*RawModel) Useable

func (r *RawModel) Useable() bool

type Reservation

type Reservation struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Addr is the IP address permanently assigned to the strategy/token combination.
	//
	// required: true
	// swagger:strfmt ipv4
	Addr net.IP
	// A description of this Reservation.  This should tell what it is for,
	// any special considerations that should be taken into account when
	// using it, etc.
	Description string
	// Documentation of this reservation.  This should tell what
	// the reservation is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// Token is the unique identifier that the strategy for this Reservation should use.
	//
	// required: true
	Token string
	// Subnet is the name of the Subnet that this Reservation is associated with.
	// This property is read-only.
	//
	Subnet string
	// NextServer is the address the server should contact next. You
	// should only set this if you want to talk to a DHCP or TFTP server
	// other than the one provided by dr-provision.
	//
	// required: false
	// swagger:strfmt ipv4
	NextServer net.IP
	// Options is the list of DHCP options that apply to this Reservation
	Options []DhcpOption
	// Strategy is the leasing strategy that will be used determine what to use from
	// the DHCP packet to handle lease management.
	//
	// required: true
	Strategy string
	// Scoped indicates that this reservation is tied to a particular Subnet,
	// as determined by the reservation's Addr.
	//
	// required: true
	Scoped bool
	// Duration is the time in seconds for which a lease can be valid.
	// ExpireTime is calculated from Duration.
	Duration int32
}

Reservation tracks persistent DHCP IP address reservations.

swagger:model

func (*Reservation) AuthKey

func (r *Reservation) AuthKey() string

func (*Reservation) CanHaveActions

func (r *Reservation) CanHaveActions() bool

func (*Reservation) Fill

func (r *Reservation) Fill()

func (*Reservation) GetDescription added in v4.1.0

func (r *Reservation) GetDescription() string

GetDescription returns the object's description

func (*Reservation) GetDocumentation

func (r *Reservation) GetDocumentation() string

GetDocumentation returns the object's documentation

func (*Reservation) GetMeta

func (r *Reservation) GetMeta() Meta

func (*Reservation) Key

func (r *Reservation) Key() string

func (*Reservation) KeyName

func (r *Reservation) KeyName() string

func (*Reservation) Prefix

func (r *Reservation) Prefix() string

func (*Reservation) SetMeta

func (r *Reservation) SetMeta(d Meta)

func (*Reservation) SliceOf

func (r *Reservation) SliceOf() interface{}

func (*Reservation) ToModels

func (r *Reservation) ToModels(obj interface{}) []Model

type Role

type Role struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of the user
	//
	// required: true
	Name string
	// Claims that the role support.
	Claims []*Claim
	// Description of role
	Description string
	// Documentation of this role.  This should tell what
	// the role is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
}

Role is used to determine which operations on which API endpoints are permitted.

swagger:model

func MakeRole

func MakeRole(name string, claims ...string) *Role

func (*Role) AuthKey

func (r *Role) AuthKey() string

func (*Role) Compile

func (r *Role) Compile() Claims

func (*Role) Contains

func (a *Role) Contains(b *Role) bool

Role a contains role b if a can be used to satisfy all requests b can satisfy

func (*Role) Fill

func (r *Role) Fill()

func (*Role) GetDescription added in v4.1.0

func (r *Role) GetDescription() string

GetDescription returns the object's Description

func (*Role) GetDocumentation

func (r *Role) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Role) GetMeta

func (r *Role) GetMeta() Meta

func (*Role) Key

func (r *Role) Key() string

func (*Role) KeyName

func (r *Role) KeyName() string

func (*Role) Match

func (r *Role) Match(scope, action, specific string) bool

func (*Role) Prefix

func (r *Role) Prefix() string

func (*Role) SetMeta

func (r *Role) SetMeta(d Meta)

func (*Role) SliceOf

func (r *Role) SliceOf() interface{}

func (*Role) ToModels

func (r *Role) ToModels(obj interface{}) []Model

func (*Role) Validate

func (r *Role) Validate()

type Section

type Section map[string]interface{}

type Sections

type Sections map[string]Section

type SecureData

type SecureData struct {
	// Key is the ephemeral public key created by Seal().  It must not
	// be modified after Seal() has completed, and it must be 32 bytes
	// long.
	Key []byte
	// Nonce must be 24 bytes of cryptographically random numbers.  It is
	// populated by Seal(), and must not be modified afterwards.
	Nonce []byte
	// Payload is the encrypted payload generated by Seal().  It must
	// not be modified, and will be 16 bytes longer than the unencrypted
	// data.
	Payload []byte
}

SecureData is used to store and send access controlled Param values to the locations they are needed at. SecureData uses a simple encryption mechanism based on the NACL Box API (as implemented by libsodium, golang.org/x/crypto/nacl/box, and many others).

All fields in this struct will be marshalled into JSON as base64 encoded strings.

swagger:model

func (*SecureData) Marshal

func (s *SecureData) Marshal(peerPublicKey []byte, data interface{}) error

Marshal marshals the passed-in data into JSON and calls Seal() with peerPublicKey and the marshalled data.

func (*SecureData) Open

func (s *SecureData) Open(targetPrivateKey *[32]byte) ([]byte, error)

Open opens a sealed SecureData item. It takes the private key that matches the peerPublicKey passed to the Seal() operation. If the SecureData object has not been corrupted or tampered with, Open() will return the decrypted data , otherwise it will return an error.

Open performs the following operations internally:

  • Validate that the lengths of all the fields of the SecureData struct are within expected ranges. This is not required for correctness, but it alows us to return nicer errors.
  • Extract the stored ephemeral public key and nonce from the SecureData object.
  • Decrypt Payload using the extracted nonce, the extracted public key, and the passed-in private key.
  • If any errors were returned in the decrypt process, return a Corrupt error, otherwise return the decrypted data.

func (*SecureData) Seal

func (s *SecureData) Seal(peerPublicKey *[32]byte, data []byte) error

Seal takes curve25519 public key advertised by where the payload should be stored, and fills in the SecureData with the data required for the Open operation to succeed.

Seal performs the following operations internally:

  • Generate ephemeral cuve25519 public and private keys from the system's cryptographically secure random number generator.
  • Generate a 24 byte nonce from the same random number generator used to create the keys.
  • Encrypt the data using the peer public key, the ephemeral private key, and the generated nonce.
  • Populate s.Key with the ephemeral public key, s.Nonce with the generated nonce, and s.Payload with the encrypted data.

func (*SecureData) Unmarshal

func (s *SecureData) Unmarshal(targetPrivateKey []byte, res interface{}) error

func (*SecureData) Validate

func (s *SecureData) Validate() error

Validate makes sure that the lengths we expect for the Key and Nonce are correct.

type Slicer

type Slicer interface {
	Filler
	SliceOf() interface{}
	ToModels(interface{}) []Model
}

Slicer interface defines is a model can be operated on as slices

func New

func New(prefix string) (Slicer, error)

New returns a new blank instance of the Model with the passed-in prefix.

type Stage

type Stage struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Partialed
	// The name of the stage.
	//
	// required: true
	Name string
	// A description of this stage.  This should tell what it is for,
	// any special considerations that should be taken into account when
	// using it, etc.
	Description string
	// Documentation of this stage.  This should tell what
	// the stage is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// The templates that should be expanded into files for the stage.
	//
	// required: true
	Templates []TemplateInfo
	// The list of extra required parameters for this
	// stage. They should be present as Machine.Params when
	// the stage is applied to the machine.
	//
	// required: true
	RequiredParams []string
	// The list of extra optional parameters for this
	// stage. They can be present as Machine.Params when
	// the stage is applied to the machine.  These are more
	// other consumers of the stage to know what parameters
	// could additionally be applied to the stage by the
	// renderer based upon the Machine.Params
	//
	OptionalParams []string
	// Params contains parameters for the stage.
	// This allows the machine to access these values while in this stage.
	Params map[string]interface{}
	// The BootEnv the machine should be in to run this stage.
	// If the machine is not in this bootenv, the bootenv of the
	// machine will be changed.
	//
	// required: true
	BootEnv string
	// The list of initial machine tasks that the stage should run
	Tasks []string
	// The list of profiles a machine should use while in this stage.
	// These are used after machine profiles, but before global.
	Profiles []string
	// Flag to indicate if a node should be PXE booted on this
	// transition into this Stage.  The nextbootpxe and reboot
	// machine actions will be called if present and Reboot is true
	Reboot bool
	// This flag is deprecated and will always be TRUE.
	RunnerWait bool
}

Stage encapsulates a set of tasks and profiles to apply to a Machine in a BootEnv.

swagger:model

func (*Stage) AuthKey

func (s *Stage) AuthKey() string

AuthKey returns the value that should be validated against claims

func (*Stage) CanHaveActions

func (s *Stage) CanHaveActions() bool

CanHaveActions returns if the object can have actions from plugins

func (*Stage) Fill

func (s *Stage) Fill()

Fill initializes the object

func (*Stage) GetBootEnv

func (s *Stage) GetBootEnv() string

GetBootEnv gets the name of the bootenv on this stage

func (*Stage) GetDescription added in v4.1.0

func (s *Stage) GetDescription() string

GetDescription returns the object's Description

func (*Stage) GetDocumentation

func (s *Stage) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Stage) GetMeta

func (s *Stage) GetMeta() Meta

GetMeta gets the meta data for this object

func (*Stage) GetParams

func (s *Stage) GetParams() map[string]interface{}

GetParams gets the parameters on this stage

func (*Stage) GetProfiles

func (s *Stage) GetProfiles() []string

GetProfiles gets the profiles on this stage

func (*Stage) GetTasks

func (s *Stage) GetTasks() []string

GetTasks returns the tasks associated with this stage

func (*Stage) Key

func (s *Stage) Key() string

Key returns the primary index for this object

func (*Stage) KeyName

func (s *Stage) KeyName() string

KeyName returns the field of the object that is used as the primary key

func (*Stage) Prefix

func (s *Stage) Prefix() string

Prefix returns the object type

func (*Stage) SetBootEnv

func (s *Stage) SetBootEnv(be string)

SetBootEnv sets the bootenv on the stage

func (*Stage) SetMeta

func (s *Stage) SetMeta(d Meta)

SetMeta sets the meta data for this object

func (*Stage) SetName

func (s *Stage) SetName(n string)

SetName sets the name of the object

func (*Stage) SetParams

func (s *Stage) SetParams(p map[string]interface{})

SetParams sets the parameters on this stage

func (*Stage) SetProfiles

func (s *Stage) SetProfiles(p []string)

SetProfiles sets the profiles on this stage

func (*Stage) SetTasks

func (s *Stage) SetTasks(t []string)

SetTasks sets the tasks in this stage

func (*Stage) SliceOf

func (s *Stage) SliceOf() interface{}

SliceOf returns an empty slice of this type of objects

func (*Stage) ToModels

func (s *Stage) ToModels(obj interface{}) []Model

ToModels converts a slice of these specific objects to a slice of Model interfaces

func (*Stage) Validate

func (s *Stage) Validate()

Validate makes sure that the object is valid (outside of references)

type Stat

type Stat struct {
	// required: true
	Name string `json:"name"`
	// required: true
	Count int `json:"count"`
}

Stat contains a basic statistic sbout dr-provision

swagger:model

type Subnet

type Subnet struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of the subnet.
	// Subnet names must be unique
	//
	// required: true
	Name string
	// A description of this Subnet.  This should tell what it is for,
	// any special considerations that should be taken into account when
	// using it, etc.
	Description string
	// Documentation of this subnet.  This should tell what
	// the subnet is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	// Enabled indicates if the subnet should hand out leases or continue operating
	// leases if already running.
	//
	// required: true
	Enabled bool
	// Proxy indicates if the subnet should act as a proxy DHCP server.
	// If true, the subnet will not manage ip addresses but will send
	// offers to requests.  It is an error for Proxy and Unmanaged to be
	// true.
	//
	// required: true
	Proxy bool
	// Unmanaged indicates that dr-provision will never send
	// boot-related options to machines that get leases from this
	// subnet.  If false, dr-provision will send whatever boot-related
	// options it would normally send.  It is an error for Unmanaged and
	// Proxy to both be true.
	//
	// required: true
	Unmanaged bool
	// Subnet is the network address in CIDR form that all leases
	// acquired in its range will use for options, lease times, and NextServer settings
	// by default
	//
	// required: true
	// pattern: ^([0-9]+\.){3}[0-9]+/[0-9]+$
	Subnet string
	// NextServer is the address of the next server in the DHCP/TFTP/PXE
	// chain.  You should only set this if you want to transfer control
	// to a different DHCP or TFTP server.
	//
	// required: true
	// swagger:strfmt ipv4
	NextServer net.IP
	// ActiveStart is the first non-reserved IP address we will hand
	// non-reserved leases from.
	//
	// required: true
	// swagger:strfmt ipv4
	ActiveStart net.IP
	// ActiveEnd is the last non-reserved IP address we will hand
	// non-reserved leases from.
	//
	// required: true
	// swagger:strfmt ipv4
	ActiveEnd net.IP
	// ActiveLeaseTime is the default lease duration in seconds
	// we will hand out to leases that do not have a reservation.
	//
	// required: true
	ActiveLeaseTime int32
	// ReservedLeasTime is the default lease time we will hand out
	// to leases created from a reservation in our subnet.
	//
	// required: true
	ReservedLeaseTime int32
	// OnlyReservations indicates that we will only allow leases for which
	// there is a preexisting reservation.
	//
	// required: true
	OnlyReservations bool
	Options          []DhcpOption
	// Strategy is the leasing strategy that will be used determine what to use from
	// the DHCP packet to handle lease management.
	//
	// required: true
	Strategy string
	// Pickers is list of methods that will allocate IP addresses.
	// Each string must refer to a valid address picking strategy.  The current ones are:
	//
	// "none", which will refuse to hand out an address and refuse
	// to try any remaining strategies.
	//
	// "hint", which will try to reuse the address that the DHCP
	// packet is requesting, if it has one.  If the request does
	// not have a requested address, "hint" will fall through to
	// the next strategy. Otherwise, it will refuse to try any
	// remaining strategies whether or not it can satisfy the
	// request.  This should force the client to fall back to
	// DHCPDISCOVER with no requsted IP address. "hint" will reuse
	// expired leases and unexpired leases that match on the
	// requested address, strategy, and token.
	//
	// "nextFree", which will try to create a Lease with the next
	// free address in the subnet active range.  It will fall
	// through to the next strategy if it cannot find a free IP.
	// "nextFree" only considers addresses that do not have a
	// lease, whether or not the lease is expired.
	//
	// "mostExpired" will try to recycle the most expired lease in the subnet's active range.
	//
	// All of the address allocation strategies do not consider
	// any addresses that are reserved, as lease creation will be
	// handled by the reservation instead.
	//
	// We will consider adding more address allocation strategies in the future.
	//
	// required: true
	Pickers []string
}

Subnet represents a DHCP Subnet.

swagger:model

func (*Subnet) AuthKey

func (s *Subnet) AuthKey() string

func (*Subnet) CanHaveActions

func (b *Subnet) CanHaveActions() bool

func (*Subnet) Fill

func (s *Subnet) Fill()

func (*Subnet) GetDescription added in v4.1.0

func (s *Subnet) GetDescription() string

GetDescription returns the object's Description

func (*Subnet) GetDocumentation

func (s *Subnet) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Subnet) GetMeta

func (s *Subnet) GetMeta() Meta

func (*Subnet) Key

func (s *Subnet) Key() string

func (*Subnet) KeyName

func (s *Subnet) KeyName() string

func (*Subnet) Prefix

func (s *Subnet) Prefix() string

func (*Subnet) SetMeta

func (s *Subnet) SetMeta(d Meta)

func (*Subnet) SliceOf

func (b *Subnet) SliceOf() interface{}

func (*Subnet) ToModels

func (b *Subnet) ToModels(obj interface{}) []Model

func (*Subnet) Validate

func (s *Subnet) Validate()

type Task

type Task struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of this Task.  Task names must be globally unique
	//
	// required: true
	Name string
	// Description is a one-line description of this Task.
	Description string
	// Documentation should describe in detail what this task should do on a machine.
	Documentation string
	// Templates lists the templates that need to be rendered for the Task.
	//
	// required: true
	Templates []TemplateInfo
	// RequiredParams is the list of parameters that are required to be present on
	// Machine.Params or in a profile attached to the machine.
	//
	// required: true
	RequiredParams []string
	// OptionalParams are extra optional parameters that a template rendered for
	// the Task may use.
	//
	// required: true
	OptionalParams []string
	// Prerequisites are tasks that must have been run in the current
	// BootEnv before this task can be run.
	Prerequisites []string
	// ExtraRoles is a list of Roles whose Claims should be added to the default
	// set of allowable Claims when a Job based on this task is running.
	ExtraRoles []string `json:"ExtraRoles,omitempty"`
	// ExtraClaims is a raw list of Claims that should be added to the default
	// set of allowable Claims when a Job based on this task is running.
	// Any extra claims added here will be added _after_ any added by ExtraRoles
	ExtraClaims []*Claim `json:"ExtraClaims,omitempty"`
}

Task is a thing that can run on a Machine.

swagger:model

func (*Task) AuthKey

func (t *Task) AuthKey() string

func (*Task) CanHaveActions

func (t *Task) CanHaveActions() bool

func (*Task) Fill

func (t *Task) Fill()

func (*Task) GetDescription added in v4.1.0

func (t *Task) GetDescription() string

GetDescription returns the object's Description

func (*Task) GetDocumentation

func (t *Task) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Task) GetMeta

func (t *Task) GetMeta() Meta

func (*Task) Key

func (t *Task) Key() string

func (*Task) KeyName

func (t *Task) KeyName() string

func (*Task) Prefix

func (t *Task) Prefix() string

func (*Task) SetMeta

func (t *Task) SetMeta(d Meta)

func (*Task) SetName

func (t *Task) SetName(n string)

func (*Task) SliceOf

func (t *Task) SliceOf() interface{}

func (*Task) ToModels

func (t *Task) ToModels(obj interface{}) []Model

func (*Task) Validate

func (t *Task) Validate()

type TaskRunner

type TaskRunner interface {
	Tasker
	RunningTask() int
}

TaskRunner interface defines if the object can run tasks

type Tasker

type Tasker interface {
	Model
	GetTasks() []string
	SetTasks([]string)
}

Tasker interface defines if the model has a task list

type Template

type Template struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// ID is a unique identifier for this template.  It cannot change once it is set.
	//
	// required: true
	ID string
	// A description of this template
	Description string
	// Contents is the raw template.  It must be a valid template
	// according to text/template.
	//
	// required: true
	Contents string
}

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

swagger:model

func (*Template) AuthKey

func (t *Template) AuthKey() string

func (*Template) CanHaveActions

func (b *Template) CanHaveActions() bool

func (*Template) Fill

func (t *Template) Fill()

func (*Template) GetDescription added in v4.1.0

func (t *Template) GetDescription() string

GetDescription returns the object's Description

func (*Template) GetMeta

func (t *Template) GetMeta() Meta

func (*Template) Key

func (t *Template) Key() string

func (*Template) KeyName

func (t *Template) KeyName() string

func (*Template) Prefix

func (t *Template) Prefix() string

func (*Template) SetMeta

func (t *Template) SetMeta(d Meta)

func (*Template) SliceOf

func (b *Template) SliceOf() interface{}

func (*Template) ToModels

func (b *Template) ToModels(obj interface{}) []Model

func (*Template) Validate

func (t *Template) Validate()

type TemplateInfo

type TemplateInfo struct {
	// Name of the template
	//
	// required: true
	Name string
	// A text/template that specifies how to create
	// the final path the template should be
	// written to.
	//
	// required: true
	Path string
	// Link optionally references another file to put at
	// the path location.
	Link string
	// ID of the template that should be expanded.  Either
	// this or Contents should be set
	//
	// required: false
	ID string
	// Contents that should be used when this template needs
	// to be expanded.  Either this or ID should be set.
	//
	// required: false
	Contents string
	// Meta for the TemplateInfo.  This can be used by the job running
	// system and the bootenvs to handle OS, arch, and firmware differences.
	//
	// required: false
	Meta map[string]string
	// contains filtered or unexported fields
}

TemplateInfo holds information on the templates in the boot environment that will be expanded into files.

swagger:model

func (*TemplateInfo) Id

func (ti *TemplateInfo) Id() string

func (*TemplateInfo) LinkTemplate added in v4.3.0

func (ti *TemplateInfo) LinkTemplate() *template.Template

func (*TemplateInfo) PathTemplate

func (ti *TemplateInfo) PathTemplate() *template.Template

func (*TemplateInfo) SanityCheck

func (ti *TemplateInfo) SanityCheck(idx int, e ErrorAdder, missingPathOK bool)

type Tenant

type Tenant struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Name        string
	Description string
	// Documentation of this tenant.  This should tell what
	// the tenant is for, any special considerations that
	// should be taken into account when using it, etc. in rich structured text (rst).
	Documentation string
	Members       map[string][]string
	Users         []string
}

swagger:model

func (*Tenant) AuthKey

func (t *Tenant) AuthKey() string

func (*Tenant) Fill

func (t *Tenant) Fill()

func (*Tenant) GetDescription added in v4.1.0

func (t *Tenant) GetDescription() string

GetDescription returns the object's Description

func (*Tenant) GetDocumentation

func (t *Tenant) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Tenant) GetMeta

func (t *Tenant) GetMeta() Meta

func (*Tenant) Key

func (t *Tenant) Key() string

func (*Tenant) KeyName

func (t *Tenant) KeyName() string

func (*Tenant) Prefix

func (t *Tenant) Prefix() string

func (*Tenant) SetMeta

func (t *Tenant) SetMeta(d Meta)

func (*Tenant) SliceOf

func (t *Tenant) SliceOf() interface{}

func (*Tenant) ToModels

func (t *Tenant) ToModels(obj interface{}) []Model

func (*Tenant) Validate

func (t *Tenant) Validate()

type User

type User struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	// Name is the name of the user
	//
	// required: true
	Name string
	// Description of user
	Description string
	// PasswordHash is the scrypt-hashed version of the user's Password.
	//
	PasswordHash []byte `json:",omitempty"`
	// Token secret - this is used when generating user token's to
	// allow for revocation by the grantor or the grantee.  Changing this
	// will invalidate all existing tokens that have this user as a user
	// or a grantor.
	Secret string
	// Roles is a list of Roles this User has.
	//
	Roles []string
}

User is an API user of DigitalRebar Provision swagger:model

func (*User) AuthKey

func (u *User) AuthKey() string

func (*User) CanHaveActions

func (b *User) CanHaveActions() bool

func (*User) ChangePassword

func (u *User) ChangePassword(newPass string) error

func (*User) CheckPassword

func (u *User) CheckPassword(pass string) bool

func (*User) Fill

func (u *User) Fill()

func (*User) GetDescription added in v4.1.0

func (u *User) GetDescription() string

GetDescription returns the object's Description

func (*User) GetMeta

func (u *User) GetMeta() Meta

func (*User) Key

func (u *User) Key() string

func (*User) KeyName

func (u *User) KeyName() string

func (*User) Prefix

func (u *User) Prefix() string

func (*User) Sanitize

func (u *User) Sanitize() Model

func (*User) SetMeta

func (u *User) SetMeta(d Meta)

func (*User) SetName

func (b *User) SetName(n string)

func (*User) SliceOf

func (b *User) SliceOf() interface{}

func (*User) ToModels

func (b *User) ToModels(obj interface{}) []Model

func (*User) Validate

func (u *User) Validate()

type UserPassword

type UserPassword struct {
	Password string
}

swagger:model

type UserToken

type UserToken struct {
	Token string
	Info  Info
}

UserToken is an auth token for a specific User. The Token section can be used for bearer authentication.

swagger:model

type ValidateSetter

type ValidateSetter interface {
	SetValid() bool
	SetAvailable() bool
}

type Validation

type Validation struct {
	// Validated tracks whether or not the model has been validated.
	// read only: true
	Validated bool
	// Available tracks whether or not the model passed validation.
	// read only: true
	Available bool
	// If there are any errors in the validation process, they will be
	// available here.
	// read only: true
	Errors []string
	// contains filtered or unexported fields
}

Validation holds information about whether the current model is valid or not. It is designed to be embedded into structs that need post-operation validation.

swagger: model

func (*Validation) AddError

func (v *Validation) AddError(err error)

func (*Validation) ChangeForced

func (v *Validation) ChangeForced() bool

func (*Validation) ClearValidation

func (v *Validation) ClearValidation()

func (*Validation) Error

func (v *Validation) Error() string

func (*Validation) Errorf

func (v *Validation) Errorf(fmtStr string, args ...interface{})

func (*Validation) ForceChange

func (v *Validation) ForceChange()

func (*Validation) HasError

func (v *Validation) HasError() error

func (*Validation) IsAvailable

func (v *Validation) IsAvailable() bool

func (*Validation) MakeError

func (v *Validation) MakeError(code int, errType string, obj Model) error

func (*Validation) RestoreValidation

func (v *Validation) RestoreValidation(ov *Validation)

func (*Validation) SaveValidation

func (v *Validation) SaveValidation() *Validation

func (*Validation) SetAvailable

func (v *Validation) SetAvailable() bool

func (*Validation) SetInvalid

func (v *Validation) SetInvalid() bool

func (*Validation) SetValid

func (v *Validation) SetValid() bool

func (*Validation) Useable

func (v *Validation) Useable() bool

type Validator

type Validator interface {
	Validate()
	ClearValidation()
	Useable() bool
	IsAvailable() bool
	HasError() error
}

model object may define a Validate method that can be used to return errors about if the model is valid in the current datatracker.

type Whoami added in v4.3.0

type Whoami struct {
	Result struct {
		Score int       `json:",omitempty"`
		Uuid  uuid.UUID `json:",omitempty"`
		Token string    `json:",omitempty"`
	}
	Fingerprint MachineFingerprint
	MacAddrs    []string
	OnDiskUUID  string
}

Whoami contains the elements used toi fingerprint a machine, along with the results of the fingerprint comparison request

func (*Whoami) Fill added in v4.3.0

func (w *Whoami) Fill() error

Fill fills out the MacAddrs list and the MachineFingerprint from the DMI information on the machine.

func (*Whoami) FromMachine added in v4.3.0

func (w *Whoami) FromMachine(m *Machine)

FromMachine extracts the Fingerprint and HardwareAddrs fields from a Machine and populates Whoami with it.

func (*Whoami) Score added in v4.3.0

func (w *Whoami) Score(m *Machine) (score int)

Score calculates how closely the passed in Whoami matches a candidate Machine. In the current implementation, Score awards points based on the following criteria:

* 25 points if the Machine has an SSNHash that matches the one in the Whoami

* 25 points if the Machine has a CSNHash that matches the one in the Whoami

* 50 points if the Machine has a SystemUUID that matches the one in the Whoami

  • 0 to 100 points varying depending on how many memory DIMMs from the machine fingerprint are present in Whoami.
  • 0 to 100 points varying depending on how many HardwareAddrs from the Machine are present in Whoami.

* 1000 points if the machine UUID matches OnDiskUUID

If the score is less than 100 at the end of the scoring process, it is rounded down to zero. The intent is to be resilient in the face of hardware changes:

* SSNHash, CSNHash, and SystemUUID come from the motherboard.

* MemoryIds are generated deterministically from the DIMMs installed in the system

* MacAddrs comes from the physical Ethernet devices in the system.

func (*Whoami) ToMachine added in v4.3.0

func (w *Whoami) ToMachine(m *Machine)

ToMachine saves the Fingerprint and the MacAddrs fields onto the passed Machine.

type Workflow

type Workflow struct {
	Validation
	Access
	Meta
	Owned
	Bundled
	Name          string
	Description   string
	Documentation string
	Stages        []string
}

Workflow contains a list of Stages. When it is applied to a Machine, that machine's Tasks list is populated with the contents of the Stages in the Workflow.

swagger:model

func (*Workflow) AuthKey

func (w *Workflow) AuthKey() string

func (*Workflow) CanHaveActions

func (w *Workflow) CanHaveActions() bool

func (*Workflow) Fill

func (w *Workflow) Fill()

func (*Workflow) GetDescription added in v4.1.0

func (w *Workflow) GetDescription() string

GetDescription returns the object's Description

func (*Workflow) GetDocumentation

func (w *Workflow) GetDocumentation() string

GetDocumentaiton returns the object's Documentation

func (*Workflow) GetMeta

func (w *Workflow) GetMeta() Meta

func (*Workflow) Key

func (w *Workflow) Key() string

func (*Workflow) KeyName

func (w *Workflow) KeyName() string

func (*Workflow) Prefix

func (w *Workflow) Prefix() string

func (*Workflow) SetMeta

func (w *Workflow) SetMeta(d Meta)

func (*Workflow) SliceOf

func (w *Workflow) SliceOf() interface{}

func (*Workflow) ToModels

func (w *Workflow) ToModels(obj interface{}) []Model

func (*Workflow) Validate

func (w *Workflow) Validate()

Jump to

Keyboard shortcuts

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