Skip to content

Instantly share code, notes, and snippets.

@askmeegs
Created September 1, 2016 20:22
Show Gist options
  • Save askmeegs/2f3a9f29aa410c43cdbaa29a87d10e2d to your computer and use it in GitHub Desktop.
Save askmeegs/2f3a9f29aa410c43cdbaa29a87d10e2d to your computer and use it in GitHub Desktop.

//Vaquero IPMI stuff

package main

import ( "fmt"

"github.com/vmware/goipmi"

)

func main() { fmt.Println("Hello World") // make connection - obviously use different info here conn := &ipmi.Connection{Path: "www.google.com", Hostname: "myhost", Port: 8080, Username: "megan", Password: "pw", Interface: "lan"}

//construct client
nt, err := ipmi.NewClient(conn)
if err != nil {
	fmt.Printf("Error creating new client: ", err)
	return
}
_ = nt.Open()

status := &ipmi.ChassisStatusResponse{}
fmt.Println("System power on?: ", status.IsSystemPowerOn())

// type ChassisStatusResponse struct {
// 	CompletionCode
// 	PowerState        uint8
// 	LastPowerEvent    uint8
// 	State             uint8
// 	FrontControlPanel uint8
// }

//POWER CONTROL x10000000 wow
err = nt.Control(ipmi.ControlPowerUp)
if err != nil {
	fmt.Printf("\nError powering up machine :%s \n", err.Error())
	return
}

err = nt.Control(ipmi.ControlPowerDown)
if err != nil {
	fmt.Printf("\nError powering down machine:\n ", err)
	return
}

//csr := &ChassisStatusResponse{}
//fmt.Printf(csr.PowerState) 

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment