model

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PowerCapTaskTypeSnapshot = "snapshot"
	PowerCapTaskTypePatch    = "patch"
)
View Source
const (
	PowerCapTaskStatusNew        = "new"
	PowerCapTaskStatusInProgress = "in-progress"
	PowerCapTaskStatusCompleted  = "completed"
)
View Source
const (
	PowerCapOpStatusNew         = "new"
	PowerCapOpStatusInProgress  = "in-progress"
	PowerCapOpStatusFailed      = "failed"
	PowerCapOpStatusSucceeded   = "Succeeded"
	PowerCapOpStatusUnsupported = "Unsupported"
)
View Source
const (
	TransitionStatusNew           = "new"
	TransitionStatusInProgress    = "in-progress"
	TransitionStatusCompleted     = "completed"
	TransitionStatusAborted       = "aborted"
	TransitionStatusAbortSignaled = "abort-signaled"
)
View Source
const (
	TransitionTaskStatusNew         = "new"
	TransitionTaskStatusInProgress  = "in-progress"
	TransitionTaskStatusFailed      = "failed"
	TransitionTaskStatusSucceeded   = "succeeded"
	TransitionTaskStatusUnsupported = "unsupported"
)
View Source
const DefaultTaskDeadline = 5
View Source
const TransitionKeepAliveInterval = 10

Variables

This section is empty.

Functions

func Find

func Find(slice []string, val string) (int, bool)

func NewInvalidInputError

func NewInvalidInputError(Message string, CompIDs []string) (err error)

func StringSliceEquals

func StringSliceEquals(obj []string, other []string) bool

func UUIDSliceEquals

func UUIDSliceEquals(obj []uuid.UUID, other []uuid.UUID) bool

Types

type IDList

type IDList struct {
	IDs []uuid.UUID `json:"ids"`
}

type IDResp

type IDResp struct {
	ID uuid.UUID `json:"id"`
}

type LocationParameter

type LocationParameter struct {
	Xname     string `json:"xname" db:"xname"`
	DeputyKey string `json:"deputyKey,omitempty" db:"deputy_key"`
}

type LocationParameterSlice added in v2.8.0

type LocationParameterSlice []LocationParameter

func (*LocationParameterSlice) Scan added in v2.8.0

func (l *LocationParameterSlice) Scan(value interface{}) error

func (LocationParameterSlice) Value added in v2.8.0

type ManagementStateFilter

type ManagementStateFilter int
const (
	ManagementStateFilter_Nil         ManagementStateFilter = iota - 1
	ManagementStateFilter_available                         // available = 0
	ManagementStateFilter_unavailable                       //  1
	ManagementStateFilter_undefined                         //  2
)

func ToManagementStateFilter

func ToManagementStateFilter(msf string) (MSF ManagementStateFilter, err error)

func (ManagementStateFilter) String

func (msf ManagementStateFilter) String() string

type Operation

type Operation int

This pattern is from : https://yourbasic.org/golang/iota/ I think the only think we ever have to really worry about is ever changing the order of this (add/remove/re-order)

const (
	Operation_Nil         Operation = iota - 1
	Operation_On                    // On = 0
	Operation_Off                   // 1 GracfulShutdown/Off->ForceOff
	Operation_SoftRestart           // 2 GracefulRestart->ForceRestart Or GracfulShutdown/Off->ForceOff->On
	Operation_HardRestart           // 3 GracfulShutdown/Off->ForceOff->On
	Operation_Init                  // 4 GracfulShutdown/Off->ForceOff->On does not require the initial power state to be "on"
	Operation_ForceOff              // 5 ForceOff
	Operation_SoftOff               // 6 GracfulShutdown/Off
)

func ToOperationFilter

func ToOperationFilter(op string) (OP Operation, err error)

ToOperationFilter - Will return a valid Operation from string

func (Operation) EnumIndex

func (op Operation) EnumIndex() int

func (Operation) String

func (op Operation) String() string

type Passback

type Passback struct {
	StatusCode int
	Obj        interface{}
	Error      Problem7807
	IsError    bool
}

func BuildErrorPassback

func BuildErrorPassback(StatusCode int, Err error) (passback Passback)

func BuildSuccessPassback

func BuildSuccessPassback(StatusCode int, Obj interface{}) (passback Passback)

type PowerCapComponent

type PowerCapComponent struct {
	Xname          string             `json:"xname"`
	Error          string             `json:"error,omitempty"`
	Limits         *PowerCapabilities `json:"limits,omitempty"`
	PowerCapLimits []PowerCapControls `json:"powerCapLimits,omitempty"`
}

func (*PowerCapComponent) Scan added in v2.8.0

func (p *PowerCapComponent) Scan(value interface{}) error

func (PowerCapComponent) Value added in v2.8.0

func (p PowerCapComponent) Value() (driver.Value, error)

type PowerCapComponentParameter

type PowerCapComponentParameter struct {
	Xname    string                     `json:"xname"`
	Controls []PowerCapControlParameter `json:"controls"`
}

type PowerCapComponentSlice added in v2.8.0

type PowerCapComponentSlice []PowerCapComponent

func (*PowerCapComponentSlice) Scan added in v2.8.0

func (p *PowerCapComponentSlice) Scan(value interface{}) error

func (PowerCapComponentSlice) Value added in v2.8.0

type PowerCapControlParameter

type PowerCapControlParameter struct {
	Name  string `json:"name"`
	Value int    `json:"value"` //TODO is this the right data type? can it be double?
}

type PowerCapControls

type PowerCapControls struct {
	Name         string `json:"name"`
	CurrentValue *int   `json:"currentValue,omitempty"`
	MaximumValue *int   `json:"maximumValue,omitempty"`
	MinimumValue *int   `json:"minimumValue,omitempty"`
}

type PowerCapOperation

type PowerCapOperation struct {
	OperationID uuid.UUID         `json:"operationID" db:"id"`
	TaskID      uuid.UUID         `json:"taskID" db:"task_id"`
	Type        string            `json:"type" db:"type"`
	Status      string            `json:"status" db:"status"`
	Component   PowerCapComponent `json:"Component" db:"component"`

	// unclear if we should store this in the DB. as best I can tell these are always pulled from SMD when we need to
	// use them. AFAICT we never skip a pull from SMD if we've pulled this data previously.
	//
	// These are populated and used in domain.doPowerCapTask(), and its child functions
	// domain.generatePowerCapPayload() and domain.parsePowerCapRFData(). The PowerCapOperation fields are direct
	// copies of values from a https://github.com/Cray-HPE/hms-power-control/blob/v2.13.0/internal/hsm/models.go#L63-L81
	// struct.
	//
	// The etcd storage engine does persist these by virtue of saving complete objects, but since PCS apparently
	// doesn't use the stored values and isn't authoritative for them, they're omitted from the Postgres schema.
	//
	// From HSM /Inventory/ComponentEndpoints
	RfFQDN                string                  `json:"RfFQDN"`
	PowerCapURI           string                  `json:"powerCapURI"`
	PowerCapTargetURI     string                  `json:"powerCapTargetURI"`
	PowerCapControlsCount int                     `json:"powerCapControlsCount"`
	PowerCapCtlInfoCount  int                     `json:"powerCapCtlInfoCount"`
	PowerCaps             map[string]hsm.PowerCap `json:"powerCap"`
}

func NewPowerCapOperation

func NewPowerCapOperation(taskID uuid.UUID, operationType string) PowerCapOperation

type PowerCapPatchParameter

type PowerCapPatchParameter struct {
	Components []PowerCapComponentParameter `json:"components"`
}

func (*PowerCapPatchParameter) Scan added in v2.8.0

func (p *PowerCapPatchParameter) Scan(value interface{}) error

func (PowerCapPatchParameter) Value added in v2.8.0

type PowerCapSnapshotParameter

type PowerCapSnapshotParameter struct {
	Xnames []string `json:"xnames"`
}

func (*PowerCapSnapshotParameter) Scan added in v2.8.0

func (p *PowerCapSnapshotParameter) Scan(value interface{}) error

func (PowerCapSnapshotParameter) Value added in v2.8.0

type PowerCapTask

type PowerCapTask struct {
	TaskID                  uuid.UUID                  `json:"taskID" db:"id"`
	Type                    string                     `json:"type" db:"type"`
	SnapshotParameters      *PowerCapSnapshotParameter `json:"snapshotParameters,omitempty" db:"snapshot_parameters"`
	PatchParameters         *PowerCapPatchParameter    `json:"patchParameters,omitempty" db:"patch_parameters"`
	TaskCreateTime          time.Time                  `json:"taskCreateTime" db:"created"`
	AutomaticExpirationTime time.Time                  `json:"automaticExpirationTime" db:"expires"`
	TaskStatus              string                     `json:"taskStatus" db:"status"`
	OperationIDs            []uuid.UUID

	// Only populated when the task is completed, but stored in the DB, not just calculated. these save an operation
	// list summary, since we delete operation rows after completing a task.
	IsCompressed bool                   `json:"isCompressed" db:"compressed"`
	TaskCounts   PowerCapTaskCounts     `json:"taskCounts" db:"task_counts,omitempty"`
	Components   PowerCapComponentSlice `json:"components,omitempty" db:"components,omitempty"`
}

func NewPowerCapPatchTask

func NewPowerCapPatchTask(parameters PowerCapPatchParameter, expirationTimeMins int) PowerCapTask

func NewPowerCapSnapshotTask

func NewPowerCapSnapshotTask(parameters PowerCapSnapshotParameter, expirationTimeMins int) PowerCapTask

type PowerCapTaskCounts

type PowerCapTaskCounts struct {
	Total       int `json:"total"`
	New         int `json:"new"`
	InProgress  int `json:"in-progress"`
	Failed      int `json:"failed"`
	Succeeded   int `json:"succeeded"`
	Unsupported int `json:"un-supported"`
}

func (*PowerCapTaskCounts) Scan added in v2.8.0

func (p *PowerCapTaskCounts) Scan(value interface{}) error

func (PowerCapTaskCounts) Value added in v2.8.0

func (p PowerCapTaskCounts) Value() (driver.Value, error)

type PowerCapTaskCreation

type PowerCapTaskCreation struct {
	TaskID uuid.UUID `json:"taskID"`
}

type PowerCapTaskResp

type PowerCapTaskResp struct {
	TaskID                  uuid.UUID              `json:"taskID"`
	Type                    string                 `json:"type"`
	TaskCreateTime          time.Time              `json:"taskCreateTime"`
	AutomaticExpirationTime time.Time              `json:"automaticExpirationTime"`
	TaskStatus              string                 `json:"taskStatus"`
	TaskCounts              PowerCapTaskCounts     `json:"taskCounts"`
	Components              PowerCapComponentSlice `json:"components,omitempty"`
}

func (*PowerCapTaskResp) Equals

func (a *PowerCapTaskResp) Equals(b PowerCapTaskResp) bool

type PowerCapTaskRespArray

type PowerCapTaskRespArray struct {
	Tasks []PowerCapTaskResp `json:"tasks"`
}

type PowerCapabilities

type PowerCapabilities struct {
	HostLimitMax *int `json:"hostLimitMax,omitempty"`
	HostLimitMin *int `json:"hostLimitMin,omitempty"`
	PowerupPower *int `json:"powerupPower,omitempty"`
}

type PowerStateFilter

type PowerStateFilter int

This pattern is from : https://yourbasic.org/golang/iota/ I think the only think we ever have to really worry about is ever changing the order of this (add/remove/re-order)

const (
	PowerStateFilter_Nil       PowerStateFilter = iota - 1
	PowerStateFilter_On                         // on = 0
	PowerStateFilter_Off                        //  1
	PowerStateFilter_Undefined                  // 2
)

func ToPowerStateFilter

func ToPowerStateFilter(psf string) (PSF PowerStateFilter, err error)

TODO need to sanitize input! READING -> http://brandonokert.com/articles/json-management-patterns-in-go/ ToPowerStateFilter - Will return a valid PowerStateFilter from string

func (PowerStateFilter) EnumIndex

func (psf PowerStateFilter) EnumIndex() int

func (PowerStateFilter) String

func (psf PowerStateFilter) String() string

type PowerStatus

type PowerStatus struct {
	Status []PowerStatusComponent `json:"status"`
}

type PowerStatusComponent

type PowerStatusComponent struct {
	XName                     string    `json:"xname" db:"xname"`
	PowerState                string    `json:"powerState" db:"power_state"`
	ManagementState           string    `json:"managementState" db:"management_state"`
	Error                     string    `json:"error" db:"error"`
	SupportedPowerTransitions []string  `json:"supportedPowerTransitions" db:"supported_power_transitions"`
	LastUpdated               time.Time `json:"lastUpdated" db:"last_updated"`
}

func (PowerStatusComponent) MarshalJSON added in v2.8.0

func (p PowerStatusComponent) MarshalJSON() ([]byte, error)

UnmarshalJSON is a custom marshaller for PowerStatusComponent to ensure that that LastUpdated is "" if its not been set.

type PowerStatusParameter

type PowerStatusParameter struct {
	Xnames                []string `json:"xname"`
	PowerStateFilter      string   `json:"powerStateFilter"`
	ManagementStateFilter string   `json:"managementStateFilter"`
}

type Problem7807

type Problem7807 struct {
	Type_    string `json:"type"`
	Detail   string `json:"detail,omitempty"`
	Instance string `json:"instance,omitempty"`
	Status   int    `json:"status,omitempty"`
	Title    string `json:"title,omitempty"`
}

RFC 7807 compliant error payload. All fields are optional except the 'type' field.

func GetFormattedErrorMessage

func GetFormattedErrorMessage(err error, code int) Problem7807

func (Problem7807) Equals

func (obj Problem7807) Equals(other Problem7807) (equal bool)

type TaskState

type TaskState int
const (
	TaskState_Nil        TaskState = iota - 1
	TaskState_GatherData           // GatherData = 0
	TaskState_Sending              // 1 Command MAY have been sent. Can't confirm it was received.
	TaskState_Waiting              // 2 Command received. Waiting to confirm power state
	TaskState_Confirmed            // 3 Power state confirmed
)

func (TaskState) EnumIndex

func (ts TaskState) EnumIndex() int

func (TaskState) String

func (ts TaskState) String() string

type Transition

type Transition struct {
	// TransitionID is the transition's ID.
	TransitionID uuid.UUID `json:"transitionID" db:"id"`
	// Operation indicates the operation to perform, such as off or soft restart.
	Operation Operation `json:"operation" db:"operation"`
	// TaskDeadline is the time limit for completing the transition.
	TaskDeadline int `json:"taskDeadlineMinutes" db:"deadline"`
	// Location contains a list of xnames and associated credentials to apply the transition to.
	Location LocationParameterSlice `json:"location" db:"location"`
	// CreateTime is the time the transition was requested.
	CreateTime time.Time `json:"createTime" db:"created"`
	// LastActiveTime is a timestamp the power service updates regularly as long as it considers the transition active.
	// This is used to reap old transitions that have been inactive for longer than a time threshold.
	LastActiveTime time.Time `json:"lastActiveTime" db:"active"`
	// AutomaticExpirationTime is a timestamp that will always reap a transition, regardless of its active status.
	AutomaticExpirationTime time.Time `json:"automaticExpirationTime" db:"expires"`
	// Status is the current phase of the transition lifecycle.
	Status string `json:"transitionStatus" db:"status"`
	// TaskIDs are the IDs of individual tasks in the transition/
	TaskIDs []uuid.UUID

	// IsCompressed indicates if the transition has its task counts tallied.
	IsCompressed bool `json:"isCompressed" db:"compressed"`
	// TaskCounts holds aggregate counts for task states.
	TaskCounts TransitionTaskCounts `json:"taskCounts" db:"task_counts"`
	// Tasks is a list of metadata about the transition's Tasks.
	Tasks TransitionTaskRespSlice `json:"tasks,omitempty" db:"tasks"`
}

func CopyTransition

func CopyTransition(transition Transition) Transition

func ToTransition

func ToTransition(parameter TransitionParameter, expirationTimeMins int) (TR Transition, err error)

type TransitionAbortResp

type TransitionAbortResp struct {
	AbortStatus string `json:"abortStatus"`
}

type TransitionCreation

type TransitionCreation struct {
	TransitionID uuid.UUID `json:"transitionID"`
	Operation    string    `json:"operation"`
}

type TransitionPage

type TransitionPage struct {
	ID           string               `json:"ID"`
	TransitionID uuid.UUID            `json:"transitionID"`
	Index        int                  `json:"index"`
	Location     []LocationParameter  `json:"location"`
	Tasks        []TransitionTaskResp `json:"tasks,omitempty"`
	TaskIDs      []uuid.UUID
}

type TransitionParameter

type TransitionParameter struct {
	Operation    string              `json:"operation"`
	TaskDeadline *int                `json:"taskDeadlineMinutes"`
	Location     []LocationParameter `json:"location"`
}

type TransitionResp

type TransitionResp struct {
	TransitionID            uuid.UUID               `json:"transitionID"`
	Operation               string                  `json:"operation"`
	CreateTime              time.Time               `json:"createTime"`
	AutomaticExpirationTime time.Time               `json:"automaticExpirationTime"`
	TransitionStatus        string                  `json:"transitionStatus"`
	TaskCounts              TransitionTaskCounts    `json:"taskCounts"`
	Tasks                   TransitionTaskRespSlice `json:"tasks,omitempty"`
}

func ToTransitionResp

func ToTransitionResp(transition Transition, tasks []TransitionTask, full bool) TransitionResp

Assembles a TransitionResp struct from a transition and an array of its tasks. If 'full' == true, full task information is included (xname, taskStatus, errors, etc).

type TransitionRespArray

type TransitionRespArray struct {
	Transitions []TransitionResp `json:"transitions"`
}

type TransitionTask

type TransitionTask struct {
	TaskID         uuid.UUID `json:"taskID" db:"id"`
	TransitionID   uuid.UUID `json:"transitionID" db:"transition_id"`
	Operation      Operation `json:"operation" db:"operation"` // != Transition.Operation Tasks the redfish power command being issued (for recovery purposes)
	State          TaskState `json:"TaskState" db:"state"`
	Xname          string    `json:"xname" db:"xname"`
	ReservationKey string    `json:"reservationKey,omitempty" db:"reservation_key"`
	DeputyKey      string    `json:"deputyKey,omitempty" db:"deputy_key"`
	Status         string    `json:"taskStatus" db:"status"`
	StatusDesc     string    `json:"taskStatusDescription" db:"status_desc"`
	Error          string    `json:"error,omitempty" db:"error"`
}

func NewTransitionTask

func NewTransitionTask(transitionID uuid.UUID, op Operation) TransitionTask

type TransitionTaskCounts

type TransitionTaskCounts struct {
	Total       int `json:"total"`
	New         int `json:"new"`
	InProgress  int `json:"in-progress"`
	Failed      int `json:"failed"`
	Succeeded   int `json:"succeeded"`
	Unsupported int `json:"un-supported"`
}

func (*TransitionTaskCounts) Scan added in v2.8.0

func (t *TransitionTaskCounts) Scan(value interface{}) error

func (TransitionTaskCounts) Value added in v2.8.0

func (t TransitionTaskCounts) Value() (driver.Value, error)

type TransitionTaskResp

type TransitionTaskResp struct {
	Xname          string `json:"xname"`
	TaskStatus     string `json:"taskStatus"`
	TaskStatusDesc string `json:"taskStatusDescription"`
	Error          string `json:"error,omitempty"`
}

type TransitionTaskRespSlice added in v2.8.0

type TransitionTaskRespSlice []TransitionTaskResp

func (*TransitionTaskRespSlice) Scan added in v2.8.0

func (t *TransitionTaskRespSlice) Scan(value interface{}) error

func (TransitionTaskRespSlice) Value added in v2.8.0

Jump to

Keyboard shortcuts

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