ipmitool

package module
v0.0.0-...-24c4bb9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 4 Imported by: 0

README

ipmitool

This ipmitool library is an ipmitool command wrapper to be used as an ipmi client.

This library is made for the purposes of Bancadati and is therefor limited in functionality and supported commands.
For now only the (chassis) power command is supported.

Requirements

This is an ipmitool wrapper and therefor it needs the ipmitool command.

Install on linux:

sudo apt install ipmitool -y

Usage

package main

import (
	"fmt"
    "log"

	"github.com/Bancadati/ipmitool"
)

func main() {
    cl, err := ipmitool.NewClient("192.198.1.1", 0, "IPMIUSER", "Password")
	if err != nil {
		log.Fatal(err)
	}

	status, err := cl.Power.Status()
	if err != nil {
		log.Fatal(err)
	}

    fmt.Println(status)

    if status == ipmitool.PowerStateOff {
		err := cl.Power.On()
		if err != nil {
			log.Fatal(err)
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Power *Power
	// contains filtered or unexported fields
}

Client represents an IPMI client

func NewClient

func NewClient(addr string, port uint16, username, password string) (*Client, error)

NewClient returns a new IPMI client Port 0 will use the default ipmi port (623)

type Power

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

Power represents the ipmi power command

func NewPower

func NewPower(cl *Client) *Power

NewPower returns a new instance of the ipmi power sub command

func (*Power) Cycle

func (p *Power) Cycle() error

Cycle sends a power cycle command to the ipmi server

func (*Power) Off

func (p *Power) Off() error

Off sends a power off command to the ipmi server

func (*Power) On

func (p *Power) On() error

On sends a power on command to the ipmi server

func (*Power) Status

func (p *Power) Status() (PowerState, error)

Status fetches the current power state of the ipmi server

type PowerState

type PowerState string

PowerState represents an IPMI node/server state of power

const (
	// PowerStateOn represents a powered on state
	PowerStateOn PowerState = "on"
	// PowerStateOff represents a powered off state
	PowerStateOff PowerState = "off"
	// PowerStateUnknown represents an unknown power state
	PowerStateUnknown PowerState = "unknown"
)

Jump to

Keyboard shortcuts

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