Skip to content

Commit

Permalink
condition: define ServerControlTaskParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Mar 18, 2024
1 parent 9e07088 commit eb6d239
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions condition/server_control.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package condition

import "github.com/google/uuid"

type (
ServerControlAction string
)

const (
// ServerControl identifies the Condition kind to power on/off/cycle servers and set the next boot device.
ServerControl Kind = "serverControl"

// SetPowerState sets the server power state
//
// Accepted ActionParameter value, one of:
// - on
// - off
// - cycle
// - reset
// - soft
SetPowerState ServerControlAction = "set_power_state"

// GetPowerState retrieves the current power state on the server.
GetPowerState ServerControlAction = "get_power_state"

// SetNextBootDevice sets the next boot device
//
// Required: false
//
// Accepted ActionParameter value, one of:
// - bios
// - cdrom
// - diag
// - floppy
// - disk
// - none
// - pxe
// - remote_drive
// - sd_card
// - usb
// - utilities
SetNextBootDevice ServerControlAction = "set_next_boot_device"

// PowerCycleBMC power cycles the BMC
PowerCycleBMC ServerControlAction = "power_cycle_bmc"
)

// ServerControlTaskParameters are the parameters that are passed for the ServerControl condition.
// nolint:govet // prefer readability over fieldalignment for this case
type ServerControlTaskParameters struct {
// Identifier for the Asset in the Asset store.
//
// Required: true
AssetID uuid.UUID `json:"asset_id"`

// The server control action to be performed
//
// Required: true
Action ServerControlAction `json:"action"`

// Action parameter to the ServerControlAction
//
// Required for SetPowerState, SetNextBootDevice actions
ActionParameter string `json:"action_parameter"`

// Persist next boot device
// For use with SetNextBootDevice action.
// Required: false
SetNextBootDevicePersistent bool `json:"set_next_boot_device_persistent"`

// Set next boot device to be UEFI
// For use with SetNextBootDevice action.
// Required: false
SetNextBootDeviceEFI bool `json:"set_next_boot_device_efi"`
}

func NewServerControlTaskParameters(assetID uuid.UUID, action ServerControlAction, controlParam string, bootDevicePersistent, efiBoot bool) *ServerControlTaskParameters {
return &ServerControlTaskParameters{
AssetID: assetID,
Action: action,
ActionParameter: controlParam,
SetNextBootDevicePersistent: bootDevicePersistent,
SetNextBootDeviceEFI: efiBoot,
}
}

0 comments on commit eb6d239

Please sign in to comment.