goipmi icon indicating copy to clipboard operation
goipmi copied to clipboard

some useage case

Open madwolfcrazy opened this issue 4 years ago • 1 comments

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 avatar Oct 27 '20 03:10 madwolfcrazy

@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

rgl avatar Jul 22 '21 16:07 rgl