goipmi
goipmi copied to clipboard
some useage case
I am using this library recently, Summarized a few examples, hope helpful for you
// init connection
newConn := ipmi.Connection{
Hostname: job.IPMIIP,
Port: 623,
Username: job.IPMIUser,
Password: job.IPMIPWD,
Interface: "lanplus",
}
cli, err := ipmi.NewClient(&newConn)
if err != nil {
log.Print(err)
return err
}
defer cli.Close()
// set machine next boot mode is PXE boot
err = cli.SetBootDevice(ipmi.BootDevicePxe)
if err != nil {
log.Println("set boot PXE", err)
return err
}
// restart machine
time.Sleep(2 * time.Second)
err = cli.Control(ipmi.ControlPowerHardReset)
if err != nil {
return err
}
BTW, I can't find some way to get power status , any idea?
@madwolfcrazy for the power status, following the code at https://github.com/talos-systems/sidero/blob/7cdae7b616db7720627ab2e5b409e2f22b0085e0/app/sidero-controller-manager/internal/power/ipmi/ipmi.go#L51 might help.
please note that you might need to use the goipmi fork at https://github.com/talos-systems/goipmi