1 Star 0 Fork 0

叶海丰/ipmi-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cmd_set_power_restore_policy.go 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
叶海丰 提交于 2024-08-02 08:43 . init
package ipmi
import "fmt"
// 28.8 Set Power Restore Policy Command
type SetPowerRestorePolicyRequest struct {
PowerRestorePolicy
}
type SetPowerRestorePolicyResponse struct {
SupportPolicyAlwaysOn bool // chassis supports always powering up after AC/mains returns
SupportPolicyPrevious bool // chassis supports restoring power to state that was in effect when AC/mains was lost
SupportPolicyAlwaysOff bool // chassis supports staying powered off after AC/mains returns
}
func (req *SetPowerRestorePolicyRequest) Pack() []byte {
out := make([]byte, 1)
packUint8(uint8(req.PowerRestorePolicy), out, 0)
return out
}
func (req *SetPowerRestorePolicyRequest) Command() Command {
return CommandSetPowerRestorePolicy
}
func (res *SetPowerRestorePolicyResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *SetPowerRestorePolicyResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShortWith(len(msg), 1)
}
b, _, _ := unpackUint8(msg, 0)
res.SupportPolicyAlwaysOff = isBit0Set(b)
res.SupportPolicyPrevious = isBit1Set(b)
res.SupportPolicyAlwaysOn = isBit2Set((b))
return nil
}
func (res *SetPowerRestorePolicyResponse) Format() string {
return fmt.Sprintf(`Policy always-off : %s"
Policy always-on : %s
Policy previous :"%s`,
formatBool(res.SupportPolicyAlwaysOff, "supported", "unsupported"),
formatBool(res.SupportPolicyAlwaysOff, "supported", "unsupported"),
formatBool(res.SupportPolicyAlwaysOff, "supported", "unsupported"),
)
}
func (c *Client) SetPowerRestorePolicy(policy PowerRestorePolicy) (response *SetPowerRestorePolicyResponse, err error) {
request := &SetPowerRestorePolicyRequest{
PowerRestorePolicy: policy,
}
response = &SetPowerRestorePolicyResponse{}
err = c.Exchange(request, response)
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rogax/ipmi-go.git
git@gitee.com:rogax/ipmi-go.git
rogax
ipmi-go
ipmi-go
3b6556707aea

搜索帮助