Created
September 1, 2016 11:54
-
-
Save ebraminio/c228ec2cfba4c09cb4717ffd6dc28dc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gist.github.com/DavidWittman/b7a509632ed92fccf237 (SuperMicro) | |
package main | |
import ( | |
"fmt" | |
"net" | |
"github.com/vmware/goipmi" | |
) | |
type macAddrResponse struct { | |
ipmi.CompletionCode | |
_ [4]byte | |
Mac [6]byte | |
} | |
func main() { | |
ipmiReq := &ipmi.Request{ | |
NetworkFunction: ipmi.NetworkFunction(0x30), | |
Command: ipmi.Command(0x21), | |
Data: []byte{}, | |
} | |
ipmiRes := &macAddrResponse{} | |
conn := &ipmi.Connection{ | |
Hostname: "IP", | |
Port: 623, | |
Username: "USER", | |
Password: "PASS", | |
Interface: "lanplus", | |
} | |
client, err := ipmi.NewClient(conn) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
err = client.Send(ipmiReq, ipmiRes) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
var mac net.HardwareAddr | |
mac = ipmiRes.Mac[:] | |
fmt.Println(mac.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment