storage

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelperRandStringSlice

func HelperRandStringSlice(num int) (ret []string)

func ToHsmDataFromStorable

func ToHsmDataFromStorable(from HsmDataStorable) (to hsm.HsmData)

Types

type Action

type Action struct {
	ActionID     uuid.UUID        `json:"id"`
	SnapshotID   uuid.UUID        `json:"snapshotID,omitempty"`
	Command      Command          `json:"command"`
	StartTime    sql.NullTime     `json:"startTime"`
	EndTime      sql.NullTime     `json:"endTime"`
	State        *fsm.FSM         `json:"state"`
	RefreshTime  sql.NullTime     `json:"refreshTime"`
	Parameters   ActionParameters `json:"parameters"`
	OperationIDs []uuid.UUID      `json:"operationIDs"`
	BlockedBy    []uuid.UUID      `json:"blockedBy"`
	Errors       []string         `json:"errors"`
}

func HelperGetStockAction

func HelperGetStockAction() (a Action)

func NewAction

func NewAction(params ActionParameters) *Action

func ToActionFromStorable

func ToActionFromStorable(from ActionStorable, id uuid.UUID) (to Action)

Added id - workaround for incorrect storage from v1.26.0 id will overwrite ActionID if ActionID is Nil

func (*Action) Equals

func (obj *Action) Equals(other Action) bool

type ActionID

type ActionID struct {
	ActionID uuid.UUID `json:"actionID"`
}

func NewActionID

func NewActionID() (id ActionID)

type ActionParameters

type ActionParameters struct {
	StateComponentFilter    StateComponentFilter    `json:"stateComponentFilter,omitempty"`
	InventoryHardwareFilter InventoryHardwareFilter `json:"inventoryHardwareFilter,omitempty"`
	ImageFilter             ImageFilter             `json:"imageFilter,omitempty"`
	TargetFilter            TargetFilter            `json:"targetFilter,omitempty"`
	Command                 Command                 `json:"command"`
}

func (*ActionParameters) Equals

func (obj *ActionParameters) Equals(other ActionParameters) bool

type ActionStorable

type ActionStorable struct {
	ActionID     uuid.UUID
	SnapshotID   uuid.UUID
	Command      Command
	StartTime    sql.NullTime     `json:"startTime"`
	EndTime      sql.NullTime     `json:"endTime"`
	State        string           `json:"state"`
	RefreshTime  sql.NullTime     `json:"refreshTime"`
	Parameters   ActionParameters `json:"parameters"`
	OperationIDs []uuid.UUID      `json:"operationIDs"`
	BlockedBy    []uuid.UUID      `json:"blockedBy"`
	Errors       []string         `json:"errors"`
}

func ToActionStorable

func ToActionStorable(from Action) (to ActionStorable)

type ActionStorableID added in v1.29.0

type ActionStorableID struct {
	ActionID uuid.UUID `json:"id"`
}

type Command

type Command struct {
	OverrideDryrun             bool `json:"overrideDryrun"`
	RestoreNotPossibleOverride bool `json:"restoreNotPossibleOverride"` // it is probable in many cases that there will NOT be any return
	// image to go back to. In that case we should NOT update unless the override is set, that way we can always get back
	OverwriteSameImage bool   `json:"overwriteSameImage"`  // If to and from version are the same, update anyways
	TimeLimit_Seconds  int    `json:"timeLimit,omitempty"` //IDEA IS THAT IT WILL BE SECONDS
	Version            string `json:"version"`             //earliest, latest
	Tag                string `json:"tag"`
	Description        string `json:"description"` //WHY are you doing this action?
}

The addition of TAG to command makes this more of a last second sanity check. We had the option to add Tags to imageFilter, however if we did that we would always expect an image filter. We had been implicitly using tag, in that we expected the image.Tags to be (contain) 'default' otherwise we would NOT match. It is possible that by putting tag in command that there may be extra operations that get set at noSolution at the last possible second, whereas a more preemptive approach would be to filter images that dont bare that tag. B/c tag was being used implicitly we decided to put it in command instead of in imageFilter. Tags does NOT impact the use of an imageID, or the taking of a snapshot. B/c in both of those cases the Version is set to explicit

func (*Command) Equals

func (obj *Command) Equals(other Command) bool

type Device

type Device struct {
	Xname   string   `json:"xname,omitempty"`
	Targets []Target `json:"targets,omitempty"`
	Error   error    `json:"error,omitempty"`
}

TODo add Error into the swagger!

func HelperGetFakeSnapshotDevices

func HelperGetFakeSnapshotDevices(fakeXname string, numDevices int) (sd Device)

func ToDeviceFromStorable

func ToDeviceFromStorable(from DeviceStorable) (to Device)

func ToDevicesFromStorable added in v1.27.0

func ToDevicesFromStorable(from []DeviceStorable) (to []Device)

func (*Device) Equals

func (obj *Device) Equals(other Device) (equals bool)

type DeviceStorable

type DeviceStorable struct {
	Xname   string           `json:"xname,omitempty"`
	Targets []TargetStorable `json:"targets,omitempty"`
	Error   string           `json:"error,omitempty"`
}

func ToDeviceStorable

func ToDeviceStorable(from Device) (to DeviceStorable)

type ETCDStorage

type ETCDStorage struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func (*ETCDStorage) DeleteAction

func (e *ETCDStorage) DeleteAction(actionID uuid.UUID) (err error)

func (*ETCDStorage) DeleteImage

func (e *ETCDStorage) DeleteImage(imageID uuid.UUID) (err error)

func (*ETCDStorage) DeleteOperation

func (e *ETCDStorage) DeleteOperation(operationID uuid.UUID) (err error)

func (*ETCDStorage) DeleteSnapshot

func (e *ETCDStorage) DeleteSnapshot(name string) (err error)

func (*ETCDStorage) DeleteSnapshotDevices added in v1.27.0

func (e *ETCDStorage) DeleteSnapshotDevices(snapshotName string) (err error)

func (*ETCDStorage) GetAction

func (e *ETCDStorage) GetAction(actionID uuid.UUID) (a Action, err error)

func (*ETCDStorage) GetActions

func (e *ETCDStorage) GetActions() (a []Action, err error)

func (*ETCDStorage) GetAllOperations added in v1.27.0

func (e *ETCDStorage) GetAllOperations() (o []Operation, err error)

func (*ETCDStorage) GetImage

func (e *ETCDStorage) GetImage(imageID uuid.UUID) (i Image, err error)

func (*ETCDStorage) GetImages

func (e *ETCDStorage) GetImages() (i []Image, err error)

func (*ETCDStorage) GetOperation

func (e *ETCDStorage) GetOperation(operationID uuid.UUID) (o Operation, err error)

func (*ETCDStorage) GetOperations

func (e *ETCDStorage) GetOperations(actionID uuid.UUID) (o []Operation, err error)

func (*ETCDStorage) GetSnapshot

func (e *ETCDStorage) GetSnapshot(name string) (ss Snapshot, err error)

func (*ETCDStorage) GetSnapshots

func (e *ETCDStorage) GetSnapshots() (s []Snapshot, err error)

func (*ETCDStorage) Init

func (e *ETCDStorage) Init(Logger *logrus.Logger) (err error)

func (*ETCDStorage) Ping

func (e *ETCDStorage) Ping() (err error)

func (*ETCDStorage) StoreAction

func (e *ETCDStorage) StoreAction(a Action) (err error)

func (*ETCDStorage) StoreImage

func (e *ETCDStorage) StoreImage(i Image) (err error)

func (*ETCDStorage) StoreOperation

func (e *ETCDStorage) StoreOperation(o Operation) (err error)

StoreOperation -> as part of this process we will delete the hsmdata; creds!

func (*ETCDStorage) StoreSnapshot

func (e *ETCDStorage) StoreSnapshot(s Snapshot) (err error)

func (*ETCDStorage) StoreSnapshotDevice added in v1.27.0

func (e *ETCDStorage) StoreSnapshotDevice(s Snapshot, d Device) (err error)

type HsmDataStorable

type HsmDataStorable struct {
	ID           string           `json:"id,omitempty"`
	Type         string           `json:"type"`
	Hostname     string           `json:"hostname,omitempty"`
	Domain       string           `json:"domain,omitempty"`
	FQDN         string           `json:"FQDN"`
	UpdateURI    string           `json:"updateURI"`
	InventoryURI string           `json:"inventoryURI"`
	Role         string           `json:"role"`
	Model        string           `json:"model"`
	Manufacturer string           `json:"manufacturer"`
	Error        string           `json:"error"`
	BmcPath      string           `json:"bmdPath"'`
	RfType       string           `json:"rfType"`
	DiscInfo     rf.DiscoveryInfo `json:"discoveryInfo,omitempty"`
	ActionReset  rf.ActionReset   `json:"actionReset,omitempty"`
}

func ToHsmDataStorable

func ToHsmDataStorable(from hsm.HsmData) (to HsmDataStorable)

type Image

type Image struct {
	ImageID                           uuid.UUID       `json:"imageID"`
	CreateTime                        sql.NullTime    `json:"createTime"`
	DeviceType                        string          `json:"deviceType"`
	Manufacturer                      string          `json:"manufacturer,omitempty"`
	Models                            []string        `json:"models,omitempty"`
	SoftwareIds                       []string        `json:"softwareIds,omitempty"`
	Target                            string          `json:"target,omitempty"`
	Tags                              []string        `json:"tags,omitempty"`
	FirmwareVersion                   string          `json:"firmwareVersion"`
	SemanticFirmwareVersion           *semver.Version `json:"semanticFirmwareVersion,omitempty"`
	UpdateURI                         string          `json:"updateURI"`
	NeedManualReboot                  bool            `json:"needManualReboot"`
	WaitTimeBeforeManualRebootSeconds int             `json:"waitTimeBeforeManualRebootSeconds"`
	WaitTimeAfterRebootSeconds        int             `json:"waitTimeAfterRebootSeconds"`
	PollingSpeedSeconds               int             `json:"pollingSpeedSeconds"`
	ForceResetType                    string          `json:"forceResetType"`
	S3URL                             string          `json:"s3URL"`
	TftpURL                           string          `json:"tftpURL"`
	AllowableDeviceStates             []string        `json:"allowableDeviceStates,omitempty"`
}

TODO flush this out new rule in documentation!: the firmware version must be unique for the devicetype/manf/model;

b.c I cannot figure out WHAT tag they are running just by looking at the firmware on the device!!!

func HelperGetStockImage

func HelperGetStockImage() (i Image)

func (*Image) Equals

func (obj *Image) Equals(other Image) bool

type ImageFilter

type ImageFilter struct {
	ImageID       uuid.UUID `json:"imageID"`
	OverrideImage bool      `json:"overrideImage"`
}

this may ONLY resolve to 1 imageID

func (*ImageFilter) Equals

func (obj *ImageFilter) Equals(other ImageFilter) bool

type ImageID

type ImageID struct {
	ImageID uuid.UUID `json:"imageID"`
}

type InventoryHardwareFilter

type InventoryHardwareFilter struct {
	Manufacturer string `json:"manufacturer,omitempty"`
	Model        string `json:"model,omitempty"`
}

InventoryHardwareFilter -> queries hsm/Inventory/hardware for manufacturer/model that is in the xnameset

func (*InventoryHardwareFilter) Empty

func (obj *InventoryHardwareFilter) Empty() bool

func (*InventoryHardwareFilter) Equals

type MemStorage

type MemStorage struct {
	Logger *logrus.Logger

	Actions    map[uuid.UUID]Action
	Operations map[uuid.UUID]Operation
	Images     map[uuid.UUID]Image
	Snapshots  map[string]Snapshot
	// contains filtered or unexported fields
}

func (*MemStorage) DeleteAction

func (b *MemStorage) DeleteAction(actionID uuid.UUID) (err error)

func (*MemStorage) DeleteImage

func (b *MemStorage) DeleteImage(imageID uuid.UUID) (err error)

func (*MemStorage) DeleteOperation

func (b *MemStorage) DeleteOperation(operationID uuid.UUID) (err error)

func (*MemStorage) DeleteSnapshot

func (b *MemStorage) DeleteSnapshot(name string) (err error)

func (*MemStorage) GetAction

func (b *MemStorage) GetAction(actionID uuid.UUID) (a Action, err error)

func (*MemStorage) GetActions

func (b *MemStorage) GetActions() (a []Action, err error)

err always nil

func (*MemStorage) GetAllOperations added in v1.27.0

func (b *MemStorage) GetAllOperations() (o []Operation, err error)

func (*MemStorage) GetImage

func (b *MemStorage) GetImage(imageID uuid.UUID) (i Image, err error)

func (*MemStorage) GetImages

func (b *MemStorage) GetImages() (i []Image, err error)

err always nil

func (*MemStorage) GetOperation

func (b *MemStorage) GetOperation(operationID uuid.UUID) (o Operation, err error)

func (*MemStorage) GetOperations

func (b *MemStorage) GetOperations(actionID uuid.UUID) (o []Operation, err error)

func (*MemStorage) GetSnapshot

func (b *MemStorage) GetSnapshot(name string) (s Snapshot, err error)

func (*MemStorage) GetSnapshots

func (b *MemStorage) GetSnapshots() (s []Snapshot, err error)

func (*MemStorage) Init

func (b *MemStorage) Init(Logger *logrus.Logger) (err error)

func (*MemStorage) Ping

func (b *MemStorage) Ping() (err error)

func (*MemStorage) StoreAction

func (b *MemStorage) StoreAction(a Action) (err error)

err is always nil

func (*MemStorage) StoreImage

func (b *MemStorage) StoreImage(i Image) (err error)

err is always nil

func (*MemStorage) StoreOperation

func (b *MemStorage) StoreOperation(o Operation) (err error)

err always nil

func (*MemStorage) StoreSnapshot

func (b *MemStorage) StoreSnapshot(s Snapshot) (err error)

err always nil

type Operation

type Operation struct {
	OperationID            uuid.UUID    `json:"operationID"`
	ActionID               uuid.UUID    `json:"actionID"`
	AutomaticallyGenerated bool         `json:"automaticallyGenerated,omitempty"`
	StartTime              sql.NullTime `json:"timeStart"`
	EndTime                sql.NullTime `json:"timeEnd"`
	ExpirationTime         sql.NullTime `json:"expirationTime"`
	RefreshTime            sql.NullTime `json:"refreshTime"` //when the record was last updated
	StateHelper            string       `json:"stateHelper"`
	State                  *fsm.FSM     `json:"state"`
	Error                  error        `json:"error"`
	Xname                  string       `json:"xname"`
	DeviceType             string       `json:"deviceType"`
	Target                 string       `json:"target"`
	TargetName             string       `json:"targetName"`
	Manufacturer           string       `json:"manufacturer"`
	Model                  string       `json:"model"`
	SoftwareId             string       `json:"softwareId"`
	FromFirmwareVersion    string       `json:"fromFirmwareVersion"` //mVersionCurrent
	FromImageID            uuid.UUID    `json:"fromImageID"`
	ToImageID              uuid.UUID    `json:"toImageID"`
	HsmData                hsm.HsmData  `json:"hsmData"`
	BlockedBy              []uuid.UUID  `json:"blockedBy"`
	TaskLink               string       `json:"taskLink"`
	UpdateInfoLink         string       `json:"updateInfoLink"`
}

func HelperGetStockOperation

func HelperGetStockOperation() (o Operation)

func NewOperation

func NewOperation() *Operation

func ToOperationFromStorable

func ToOperationFromStorable(from OperationStorable) (to Operation)

func (*Operation) Equals

func (obj *Operation) Equals(other Operation) bool

type OperationStorable

type OperationStorable struct {
	OperationID            uuid.UUID       `json:"operationID"`
	ActionID               uuid.UUID       `json:"actionID"`
	AutomaticallyGenerated bool            `json:"automaticallyGenerated,omitempty"`
	StartTime              sql.NullTime    `json:"startTime"`
	EndTime                sql.NullTime    `json:"endTime"`
	ExpirationTime         sql.NullTime    `json:"expirationTime"`
	RefreshTime            sql.NullTime    `json:"refreshTime"` //when the record was last updated
	StateHelper            string          `json:"stateHelper"`
	State                  string          `json:"state"`
	Error                  string          `json:"error"`
	Xname                  string          `json:"xname"`
	DeviceType             string          `json:"deviceType"`
	Target                 string          `json:"target"`
	TargetName             string          `json:"targetName"`
	Manufacturer           string          `json:"manufacturer"`
	Model                  string          `json:"model"`
	SoftwareId             string          `json:"softwareId"`
	FromFirmwareVersion    string          `json:"fromFirmwareVersion"` //mVersionCurrent
	FromImageID            uuid.UUID       `json:"fromImageID"`
	ToImageID              uuid.UUID       `json:"toImageID"`
	HsmData                HsmDataStorable `json:"hsmData"`
	BlockedBy              []uuid.UUID     `json:"blockedBy"`
	TaskLink               string          `json:"taskLink"`
	UpdateInfoLink         string          `json:"updateInfoLink"`
}

func ToOperationStorable

func ToOperationStorable(from Operation) (to OperationStorable)

type Snapshot

type Snapshot struct {
	Name              string             `json:"name"`
	CaptureTime       sql.NullTime       `json:"captureTime"`
	ExpirationTime    sql.NullTime       `json:"expirationTime"`
	Ready             bool               `json:"ready"`
	Devices           []Device           `json:"devices"`
	RelatedActions    []uuid.UUID        `json:"relatedActions"`
	Parameters        SnapshotParameters `json:"parameters"`
	Errors            []string           `json:"errors"`
	UniqueDeviceCount int                `json:"uniqueDeviceCount"`
}

func HelperGetFilledSnapshot

func HelperGetFilledSnapshot(numDevice int) (s Snapshot)

func HelperGetStockSnapshot

func HelperGetStockSnapshot() (s Snapshot)

func HelperGetStockSnapshotFixedDate

func HelperGetStockSnapshotFixedDate() (s Snapshot)

func ToSnapshotFromStorable

func ToSnapshotFromStorable(from SnapshotStorable) (to Snapshot)

func (*Snapshot) Equals

func (obj *Snapshot) Equals(other Snapshot) bool

type SnapshotParameters

type SnapshotParameters struct {
	Name                    string                  `json:"name"`
	ExpirationTime          sql.NullTime            `json:"expirationTime,omitempty"`
	StateComponentFilter    StateComponentFilter    `json:"stateComponentFilters,omitempty"`
	InventoryHardwareFilter InventoryHardwareFilter `json:"inventoryHardwareFilters,omitempty"`
	TargetFilter            TargetFilter            `json:"targetFilter,omitempty"`
}

func ToSnapshotParametersFromStorable

func ToSnapshotParametersFromStorable(from SnapshotParametersStorable) (to SnapshotParameters)

func (*SnapshotParameters) Equals

func (obj *SnapshotParameters) Equals(other SnapshotParameters) bool

type SnapshotParametersStorable

type SnapshotParametersStorable struct {
	Name                    string                  `json:"name"`
	ExpirationTime          sql.NullTime            `json:"expirationTime,omitempty"`
	StateComponentFilter    StateComponentFilter    `json:"stateComponentFilters,omitempty"`
	InventoryHardwareFilter InventoryHardwareFilter `json:"inventoryHardwareFilters,omitempty"`
	TargetFilter            TargetFilter            `json:"targetFilter,omitempty"`
}

func ToSnapshotParametersStorable

func ToSnapshotParametersStorable(from SnapshotParameters) (to SnapshotParametersStorable)

type SnapshotStorable

type SnapshotStorable struct {
	Name              string                     `json:"name,omitempty"`
	CaptureTime       sql.NullTime               `json:"captureTime,omitempty"`
	ExpirationTime    sql.NullTime               `json:"expirationTime,omitempty"`
	Ready             bool                       `json:"ready,omitempty"`
	RelatedActions    []uuid.UUID                `json:"relatedActions,omitempty"`
	Parameters        SnapshotParametersStorable `json:"parameters,omitempty"`
	Errors            []string                   `json:"errors"`
	Devices           []DeviceStorable           `json:"devices,omitempty"`
	UniqueDeviceCount int                        `json:"uniqueDeviceCount"`
}

func ToSnapshotStorable

func ToSnapshotStorable(from Snapshot) (to SnapshotStorable)

type Snapshots

type Snapshots struct {
	Snapshots []Snapshot `json:"snapshots"`
}

type StateComponentFilter

type StateComponentFilter struct {
	Partitions  []string `json:"partitions,omitempty"`
	Groups      []string `json:"groups,omitempty"`
	Xnames      []string `json:"xnames,omitempty"`
	DeviceTypes []string `json:"deviceTypes,omitempty"` //nodeBMC
}

StateComponentFilter -> queries hsm/state/components -> lockable components that were discovered

func (*StateComponentFilter) Equals

func (obj *StateComponentFilter) Equals(other StateComponentFilter) bool

type StorageProvider

type StorageProvider interface {
	Init(Logger *logrus.Logger) (err error)
	Ping() (err error)

	StoreAction(a Action) (err error)
	DeleteAction(actionID uuid.UUID) (err error)
	GetAction(actionID uuid.UUID) (a Action, err error)
	GetActions() (a []Action, err error)

	StoreOperation(o Operation) (err error)
	DeleteOperation(operationID uuid.UUID) (err error)
	GetOperation(operationID uuid.UUID) (o Operation, err error)
	GetOperations(actionID uuid.UUID) (o []Operation, err error)
	GetAllOperations() (o []Operation, err error)

	StoreSnapshot(s Snapshot) (err error)
	GetSnapshot(name string) (ss Snapshot, err error)
	GetSnapshots() (s []Snapshot, err error)
	DeleteSnapshot(name string) (err error)

	GetImages() (i []Image, err error)
	GetImage(imageID uuid.UUID) (i Image, err error)
	StoreImage(i Image) (err error)
	DeleteImage(imageID uuid.UUID) (err error)
}

type Target

type Target struct {
	Name            string    `json:"name,omitempty"`
	FirmwareVersion string    `json:"firmwareVersion,omitempty"`
	SoftwareId      string    `json:"softwareId,omitempty"`
	TargetName      string    `json:"targetName"`
	Error           error     `json:"error,omitempty"`
	ImageID         uuid.UUID `json:"imageID,omitempty"`
}

TODo add Error into the swagger!

func HelperGetFakeSnapshotTargets

func HelperGetFakeSnapshotTargets(fakeID string) (st Target)

func ToTargetFromStorable

func ToTargetFromStorable(from []TargetStorable) (to []Target)

func (*Target) Equals

func (obj *Target) Equals(other Target) (equals bool)

type TargetFilter

type TargetFilter struct {
	Targets []string `json:"targets,omitempty"`
}

TargetFilter -> nodeBMC, routerBMC, etc.

func (*TargetFilter) Equals

func (obj *TargetFilter) Equals(other TargetFilter) bool

type TargetStorable

type TargetStorable struct {
	Name            string `json:"name,omitempty"`
	FirmwareVersion string `json:"firmwareVersion,omitempty"`
	Error           string `json:"error,omitempty"`
	ImageID         string `json:"imageID,omitempty"`
	SoftwareId      string `json:"softwareId"`
	TargetName      string `json:"targetName"`
}

func ToTargetStorable

func ToTargetStorable(from []Target) (to []TargetStorable)

Jump to

Keyboard shortcuts

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