forked from bougou/go-ipmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_clear_sel.go
59 lines (49 loc) · 1.31 KB
/
cmd_clear_sel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ipmi
import "fmt"
// 31.9 Clear SEL Command
type ClearSELRequest struct {
ReservationID uint16 // LS Byte first
GetErasureStatusFlag bool
}
type ClearSELResponse struct {
ErasureProgressStatus uint8
}
func (req *ClearSELRequest) Pack() []byte {
var out = make([]byte, 6)
packUint16L(req.ReservationID, out, 0)
packUint8('C', out, 2) // fixed 'C' char
packUint8('L', out, 3) // fixed 'L' char
packUint8('R', out, 4) // fixed 'R' char
if req.GetErasureStatusFlag {
packUint8(0x00, out, 5) // get erasure status
} else {
packUint8(0xaa, out, 5) // initiate erase
}
return out
}
func (req *ClearSELRequest) Command() Command {
return CommandClearSEL
}
func (res *ClearSELResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShort
}
res.ErasureProgressStatus, _, _ = unpackUint8(msg, 0)
return nil
}
func (res *ClearSELResponse) CompletionCodes() map[uint8]string {
// no command-specific cc
return map[uint8]string{}
}
func (res *ClearSELResponse) Format() string {
return fmt.Sprintf("%v", res)
}
func (c *Client) ClearSEL(reservationID uint16) (response *ClearSELResponse, err error) {
request := &ClearSELRequest{
ReservationID: reservationID,
GetErasureStatusFlag: false,
}
response = &ClearSELResponse{}
err = c.Exchange(request, response)
return
}