Documentation ¶
Index ¶
- func DeviceIn(id DeviceID, ids []DeviceID) bool
- func PasswordSSHCommandRunner(password string, sshArgs ...string) *stdinRunner
- func PublicKeySSHCommandRunner(sshArgs ...string) *stdinRunner
- type CommandRunner
- type Controller
- type ControllerInitCB
- type DeviceID
- type EdgeSwitchConfig
- type SynaccessConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PasswordSSHCommandRunner ¶
PasswordSSHCommandRunner returns a CommandRunner that will operate over a native ssh binary with the following arguments. One of the provided arguments should be the user/ip address. It passes the password into ssh via sshpass. See http://manpages.ubuntu.com/manpages/trusty/man1/sshpass.1.html for more details on why sshpass is needed to give the password to ssh. Note: ssh is known to return errors even when the command executed normally. To work around this, ignore the error returned by ExecCmds and look at the standard out.
func PublicKeySSHCommandRunner ¶
func PublicKeySSHCommandRunner(sshArgs ...string) *stdinRunner
PublicKeySSHCommandRunner returns a CommandRunner that will operate over a native ssh binary with the following arguments. One of the provided arguments should be the user/ip address. It presumes that the target is configured to authenticate via a shared public key (e.g. in .ssh/authorized_keys), as it does not expect or support ssh prompting for a password.
Types ¶
type CommandRunner ¶
type CommandRunner interface { // ExecCmds executes a series of commands and returns the accumulated output of all commands. // If one command fails, an error is returned, but no other guarantees are made. ExecCmds(ctx context.Context, cmds ...string) (string, error) }
The CommandRunner interface adds a layer of abstraction around sending commands to powercycle Controllers. It is not meant to be a general purpose interface or a robust implementation beyond exactly that use.
type Controller ¶
type Controller interface { // DeviceIDs returns a list of strings that uniquely identify the devices that can be controlled // through this group. DeviceIDs() []DeviceID // PowerCycle turns the device off for a reasonable amount of time (i.e. 10 seconds) and then // turns it back on. If delayOverride is larger than zero it overrides the default delay between // turning the port off and on again. PowerCycle(ctx context.Context, id DeviceID, delayOverride time.Duration) error }
Controller abstracts a set of devices that can all be controlled together.
func ControllerFromJSON5 ¶
func ControllerFromJSON5(ctx context.Context, path string, connect bool, cb ControllerInitCB) (Controller, error)
ControllerFromJSON5 parses a JSON5 file and instantiates the defined devices. If connect is true, an attempt will be made to connect to the subclients and errors will be returned if they are not accessible. The ControllerInitCB is called once for each controller with the state for each machine it controls
func ControllerFromJSON5Bytes ¶
func ControllerFromJSON5Bytes(ctx context.Context, configFileBytes []byte, connect bool, controllerInitCallback ControllerInitCB) (Controller, error)
ControllerFromJSON5Bytes parses a JSON5 file and instantiates the defined devices. If connect is true, an attempt will be made to connect to the subclients and errors will be returned if they are not accessible. The ControllerInitCB is called once for each controller with the state for each machine it controls.
type ControllerInitCB ¶
type ControllerInitCB func(rpc.UpdatePowerCycleStateRequest) error
ControllerInitCB is a callback that is called for every Controller as it finishes initialization. The success or failure of that initialization is stored in the rpc.UpdatePowerCycleStateRequest.
type DeviceID ¶
type DeviceID string
DeviceID is a unique identifier for a given machine or attached device.
type EdgeSwitchConfig ¶
type EdgeSwitchConfig struct { // IP address of the device, i.e. 192.168.1.33 Address string `json:"address"` // User of the ssh connection. User string `json:"user"` // Password for User. This can also be set by the environment variable "POWERCYCLE_PASSWORD". Password string `json:"password"` // Mapping between device id and port on the power strip. DevPortMap map[DeviceID]int `json:"ports"` }
EdgeSwitchConfig contains configuration options for a single EdgeSwitch. Authentication is handled via a provided password. See go/skolo-powercycle-setup for more.
func (*EdgeSwitchConfig) Validate ¶
func (c *EdgeSwitchConfig) Validate() error
Validate returns an error if the configuration is not complete.