powercontrol

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package powercontrol implements API functions residing under /powercontrol. This path contains methods for querying and setting the power state of VMs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSet is raised if the power state of a VM could not be set.
	ErrSet = errors.New("could not set powerstate of VM")
	// ErrInvalidState is raised if the API retuned an unknown power state.
	ErrInvalidState = errors.New("invalid power state received")

	// OnRequest indicates that the VM shall be on.
	OnRequest Request = "on"
	// HardRebootRequest indicates that the VM shall be rebooted without involving the OS. This is currently broken in API.
	HardRebootRequest Request = "hard_reboot"
	// HardShutdownRequest indicates that the VM shall shut down without involving the OS. This is currently broken in API.
	HardShutdownRequest Request = "hard_shutdown"
	// RebootRequest indicates that the VM shall be rebooted.
	RebootRequest Request = "reboot"
	// ShutdownRequest indicates that the VM shall be shut down.
	ShutdownRequest Request = "shutdown"

	// OnState indicates that the VM is on.
	OnState State = "VM_POWER_STATE_POWERED_ON"
	// OffState indicates that the VM is off.
	OffState State = "VM_POWER_STATE_POWERED_OFF"
)

Functions

This section is empty.

Types

type API

type API interface {
	Get(ctx context.Context, vmIdentifier string) (State, error)
	// Do not use this, its broken.
	Set(ctx context.Context, vmIdentifier string, request Request) (Task, error)
	AwaitCompletion(ctx context.Context, vmID, taskID string) error
}

API contains methods for VM power control.

func NewAPI

func NewAPI(c client.Client) API

NewAPI creates a new powercontrol API instance with the given client.

type Request

type Request string

Request is the requested power state operation of a VM.

type State

type State string

State is the current power state of a VM.

type Task

type Task struct {
	Progress       int    `json:"progress"`
	VMIdentifier   string `json:"identifier"`
	TaskIdentifier string `json:"task_id"`
	Error          string `json:"error"`
}

Task inside the api to change the power state of a VM.

Jump to

Keyboard shortcuts

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