powerman

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

README

pkg/powerman

Powerman provides Go bindings for libpowerman.

While Powerman is mostly just bindings of the C library, it has been restructured to use an object interface.

See cmd/pmshell for simple usage example.

Documentation

Index

Constants

View Source
const PM_CONN_INET6 = C.PM_CONN_INET6

Variables

View Source
var StatusName = map[Status]string{
	PM_UNKNOWN: "UNKNOWN",
	PM_OFF:     "OFF",
	PM_ON:      "ON",
}

StatusName maps node Status to a string

View Source
var StatusValue = map[string]Status{
	"UNKNOWN": PM_UNKNOWN,
	"OFF":     PM_OFF,
	"ON":      PM_ON,
}

StatusValue maps a string back to a Status Value

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

A Connection represents a connection to a powerman server To initialize a connection, call Connect() Connections should be Disconnect()'ed when done

func Connect

func Connect(server string, flags int) (*Connection, error)

Connect to the powerman service

func (*Connection) All

func (c *Connection) All() []string

All uses the default iterator to get a list of all known nodes

func (*Connection) Disconnect

func (c *Connection) Disconnect()

Disconnect tears down the server connection and frees resources

func (*Connection) Next

func (c *Connection) Next() (node string, end bool)

Next gets the next node in the default iterator

func (*Connection) NodeCycle

func (c *Connection) NodeCycle(node string) error

NodeCycle tells powerman to cycle a node

func (*Connection) NodeIteratorCreate

func (c *Connection) NodeIteratorCreate() (*Iterator, error)

NodeIteratorCreate initializes an iterator that can iterate through all node names

func (*Connection) NodeOff

func (c *Connection) NodeOff(node string) error

NodeOff tells powerman to turn a node off

func (*Connection) NodeOn

func (c *Connection) NodeOn(node string) error

NodeOn tells powerman to turn on a node

func (*Connection) NodeStatus

func (c *Connection) NodeStatus(node string) (Status, error)

NodeStatus returns the status of a specific node by name

func (*Connection) Reset

func (c *Connection) Reset()

Reset resets the default iterator to the first node

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

func (*Iterator) All

func (i *Iterator) All() (nodes []string)

All gets a list of all known nodes

func (*Iterator) Next

func (i *Iterator) Next() (node string, end bool)

Next returns the next node name, or returns end == true if there are no more nodes

func (*Iterator) Reset

func (i *Iterator) Reset()

Reset rewinds the iterator to the beginning of the list

type Status

type Status C.pm_node_state_t

Status is a value describing the state of a node

const (
	PM_UNKNOWN Status = C.PM_UNKNOWN
	PM_OFF     Status = C.PM_OFF
	PM_ON      Status = C.PM_ON
)

func (Status) String

func (s Status) String() string

String gives a string representation of a Status

Jump to

Keyboard shortcuts

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