forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reboot.go
51 lines (43 loc) · 1018 Bytes
/
reboot.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
package main
import (
"fmt"
"github.com/stmcginnis/gofish"
"github.com/stmcginnis/gofish/redfish"
)
func main() {
// Create a new instance of gofish client, ignoring self-signed certs
config := gofish.ClientConfig{
Endpoint: "https://bmc-ip",
Username: "my-username",
Password: "my-password",
Insecure: true,
}
c, err := gofish.Connect(config)
if err != nil {
panic(err)
}
defer c.Logout()
// Attached the client to service root
service := c.Service
// Query the computer systems
ss, err := service.Systems()
if err != nil {
panic(err)
}
// Creates a boot override to pxe once
bootOverride := redfish.Boot{
BootSourceOverrideTarget: redfish.PxeBootSourceOverrideTarget,
BootSourceOverrideEnabled: redfish.OnceBootSourceOverrideEnabled,
}
for _, system := range ss {
fmt.Printf("System: %#v\n\n", system)
err := system.SetBoot(bootOverride)
if err != nil {
panic(err)
}
err = system.Reset(redfish.ForceRestartResetType)
if err != nil {
panic(err)
}
}
}