-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
condition: define ServerControlTaskParameters
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |