hardware

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorLockDownMode = errors.New("cannot set power: lockdown mode is enabled")

Functions

func GetJobsWithErrorInHandler

func GetJobsWithErrorInHandler() uint16

Returns the number of registered failed jobs of the last running daemon (can also be the current daemon)

func GetPendingJobCount

func GetPendingJobCount() int

Returns the number of currently pending jobs in the queue

func GetPowerState

func GetPowerState(switchId string) (bool, error)

Returns the power state of a given switch Checks if the switch exists beforehand

func Init

func Init()

func InitLogger

func InitLogger(logger *logrus.Logger)

func RunNodeCheck

func RunNodeCheck() error

Runs a health-check on all nodes of the system Used in system-level healthcheck

func SaveCurrentPowerUsage added in v0.0.57

func SaveCurrentPowerUsage() error

Takes a snapshot of the current power draw and inserts it into the database

func SaveCurrentPowerUsageWithLogs added in v0.0.57

func SaveCurrentPowerUsageWithLogs()

Wrapper around `saveCurrentPowerUsage` which handles errors through logging Is also more verbose than the original function

func SetPower

func SetPower(switchId string, powerOn bool) error

As setPower, just with additional logs and account for taking a snapshot of the power states

func SetSwitchPowerAll

func SetSwitchPowerAll(switchId string, powerOn bool, username string) error

Sets the power-state of a specific switch Checks if the switch exists Checks if the user has all required permissions Sends a power request to all available nodes

func StartPowerUsageSnapshotScheduler added in v0.0.58

func StartPowerUsageSnapshotScheduler() error

Sets up a scheduler which triggers the flushing of old power usage records

Types

type JobResult

type JobResult struct {
	Id    int64 `json:"id"`
	Error error `json:"error"`
}

func GetResults

func GetResults() []JobResult

Returns the current state of the results queue

type PowerDrawDataPointUnixMillis added in v0.0.57

type PowerDrawDataPointUnixMillis struct {
	Id   uint                   `json:"id"`
	Time uint                   `json:"time"` // Is represented as Unix-millis
	On   database.PowerDrawData `json:"on"`
	Off  database.PowerDrawData `json:"off"`
}

Just like the equivalent in the database module except the time is represented using Unix-millis

func GetPowerUsageRecordsUnixMillis added in v0.0.57

func GetPowerUsageRecordsUnixMillis(maxAgeHours int) ([]PowerDrawDataPointUnixMillis, error)

Acts like a wrapper for the `database.GetPowerUsageRecords` The main difference is that dates are transformed into unix-millis (which are easier to parse for any API client)

type PowerJob

type PowerJob struct {
	Id     int64  `json:"id"`
	Switch string `json:"switch"`
	Power  bool   `json:"power"`
}

func GetPendingJobs

func GetPendingJobs() []PowerJob

Returns the current state of the job queue

type PowerRequest

type PowerRequest struct {
	Switch string `json:"switch"`
	Power  bool   `json:"power"`
}

Jump to

Keyboard shortcuts

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