Documentation
¶
Index ¶
- Constants
- func Find(slice []string, val string) (int, bool)
- func NewInvalidInputError(Message string, CompIDs []string) (err error)
- func StringSliceEquals(obj []string, other []string) bool
- func UUIDSliceEquals(obj []uuid.UUID, other []uuid.UUID) bool
- type IDList
- type IDResp
- type LocationParameter
- type LocationParameterSlice
- type ManagementStateFilter
- type Operation
- type Passback
- type PowerCapComponent
- type PowerCapComponentParameter
- type PowerCapComponentSlice
- type PowerCapControlParameter
- type PowerCapControls
- type PowerCapOperation
- type PowerCapPatchParameter
- type PowerCapSnapshotParameter
- type PowerCapTask
- type PowerCapTaskCounts
- type PowerCapTaskCreation
- type PowerCapTaskResp
- type PowerCapTaskRespArray
- type PowerCapabilities
- type PowerStateFilter
- type PowerStatus
- type PowerStatusComponent
- type PowerStatusParameter
- type Problem7807
- type TaskState
- type Transition
- type TransitionAbortResp
- type TransitionCreation
- type TransitionPage
- type TransitionParameter
- type TransitionResp
- type TransitionRespArray
- type TransitionTask
- type TransitionTaskCounts
- type TransitionTaskResp
- type TransitionTaskRespSlice
Constants ¶
const ( PowerCapTaskTypeSnapshot = "snapshot" PowerCapTaskTypePatch = "patch" )
const ( PowerCapTaskStatusNew = "new" PowerCapTaskStatusInProgress = "in-progress" PowerCapTaskStatusCompleted = "completed" )
const ( PowerCapOpStatusNew = "new" PowerCapOpStatusInProgress = "in-progress" PowerCapOpStatusFailed = "failed" PowerCapOpStatusSucceeded = "Succeeded" PowerCapOpStatusUnsupported = "Unsupported" )
const ( TransitionStatusNew = "new" TransitionStatusInProgress = "in-progress" TransitionStatusCompleted = "completed" TransitionStatusAborted = "aborted" TransitionStatusAbortSignaled = "abort-signaled" )
const ( TransitionTaskStatusNew = "new" TransitionTaskStatusInProgress = "in-progress" TransitionTaskStatusFailed = "failed" TransitionTaskStatusSucceeded = "succeeded" TransitionTaskStatusUnsupported = "unsupported" )
const DefaultTaskDeadline = 5
const TransitionKeepAliveInterval = 10
Variables ¶
This section is empty.
Functions ¶
func NewInvalidInputError ¶
func StringSliceEquals ¶
Types ¶
type LocationParameter ¶
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
type ManagementStateFilter ¶
type ManagementStateFilter int
const ( ManagementStateFilter_Nil ManagementStateFilter = iota - 1 ManagementStateFilter_available // available = 0 ManagementStateFilter_undefined // 2 )
func ToManagementStateFilter ¶
func ToManagementStateFilter(msf string) (MSF ManagementStateFilter, err error)
func (ManagementStateFilter) EnumIndex ¶
func (msf ManagementStateFilter) EnumIndex() int
https://levelup.gitconnected.com/implementing-enums-in-golang-9537c433d6e2
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 ¶
ToOperationFilter - Will return a valid Operation from string
type Passback ¶
type Passback struct {
StatusCode int
Obj interface{}
Error Problem7807
IsError bool
}
func BuildErrorPassback ¶
func BuildSuccessPassback ¶
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
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
type PowerCapControls ¶
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
type PowerCapSnapshotParameter ¶
type PowerCapSnapshotParameter struct {
Xnames []string `json:"xnames"`
}
func (*PowerCapSnapshotParameter) Scan ¶ added in v2.8.0
func (p *PowerCapSnapshotParameter) Scan(value interface{}) error
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
type PowerCapTaskCreation ¶
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 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 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 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 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
type TransitionTaskResp ¶
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