File: cmd_chassis_identify.go

package info (click to toggle)
golang-github-bougou-go-ipmi 0.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,880 kB
  • sloc: makefile: 38
file content (55 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download | duplicates (2)
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
package ipmi

import "context"

// 28.5 Chassis Identify Command
// 用来定位设备,机箱定位 (机箱定位灯默认亮 interval 秒)
type ChassisIdentifyRequest struct {
	IdentifyInterval uint8
	ForceIdentifyOn  bool
}

type ChassisIdentifyResponse struct {
	// empty
}

func (req *ChassisIdentifyRequest) Pack() []byte {
	out := make([]byte, 2)
	packUint8(uint8(req.IdentifyInterval), out, 0)

	var force uint8 = 0
	if req.ForceIdentifyOn {
		force = 1
	}
	packUint8(force, out, 1)
	return out
}

func (req *ChassisIdentifyRequest) Command() Command {
	return CommandChassisIdentify
}

func (res *ChassisIdentifyResponse) CompletionCodes() map[uint8]string {
	return map[uint8]string{}
}

func (res *ChassisIdentifyResponse) Unpack(msg []byte) error {
	return nil
}

func (res *ChassisIdentifyResponse) Format() string {
	return ""
}

// This command causes the chassis to physically identify itself by a mechanism
// chosen by the system implementation; such as turning on blinking user-visible lights
// or emitting beeps via a speaker, LCD panel, etc.
func (c *Client) ChassisIdentify(ctx context.Context, interval uint8, force bool) (response *ChassisIdentifyResponse, err error) {
	request := &ChassisIdentifyRequest{
		IdentifyInterval: interval,
		ForceIdentifyOn:  force,
	}
	response = &ChassisIdentifyResponse{}
	err = c.Exchange(ctx, request, response)
	return
}