Skip to content

Commit 58dd9d6

Browse files
committed
Add Supermicro OEM ComputerSystem objects
This adds an OEM version of the ComputerSystem type for Supermicro systems. This enables access to the NodeManager and FixedBootOrder oem-specific objects. Signed-off-by: Sean McGinnis <[email protected]>
1 parent c4e76fb commit 58dd9d6

7 files changed

+597
-5
lines changed

oem/smc/computersystem.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
//
4+
5+
package smc
6+
7+
import (
8+
"encoding/json"
9+
10+
"github.com/stmcginnis/gofish/common"
11+
"github.com/stmcginnis/gofish/redfish"
12+
)
13+
14+
// ComputerSystem is a Supermicro OEM instance of a ComputerSystem.
15+
type ComputerSystem struct {
16+
redfish.ComputerSystem
17+
nodeManager string
18+
fixedBootOrder string
19+
}
20+
21+
// NodeManager gets the NodeManager for the system.
22+
func (cs *ComputerSystem) NodeManager() (*NodeManager, error) {
23+
return GetNodeManager(cs.GetClient(), cs.nodeManager)
24+
}
25+
26+
// FixedBootOrder gets the FixedBootOrder instance for the system.
27+
func (cs *ComputerSystem) FixedBootOrder() (*FixedBootOrder, error) {
28+
return GetFixedBootOrder(cs.GetClient(), cs.fixedBootOrder)
29+
}
30+
31+
// FromComputerSystem converts a standard ComputerSystem object to the OEM implementation.
32+
func FromComputerSystem(system *redfish.ComputerSystem) (*ComputerSystem, error) {
33+
type Oem struct {
34+
Supermicro struct {
35+
NodeManager common.Link `json:"NodeManager"`
36+
FixedBootOrder common.Link `json:"FixedBootOrder"`
37+
} `json:"Supermicro"`
38+
}
39+
40+
cs := &ComputerSystem{}
41+
err := json.Unmarshal(system.RawData, cs)
42+
if err != nil {
43+
return nil, err
44+
}
45+
46+
oem := &Oem{}
47+
err = json.Unmarshal(cs.OEM, oem)
48+
if err != nil {
49+
return nil, err
50+
}
51+
cs.nodeManager = oem.Supermicro.NodeManager.String()
52+
cs.fixedBootOrder = oem.Supermicro.FixedBootOrder.String()
53+
54+
cs.SetClient(system.GetClient())
55+
return cs, nil
56+
}

oem/smc/computersystem_test.go

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
//
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
//
4+
5+
package smc
6+
7+
import (
8+
"encoding/json"
9+
"strings"
10+
"testing"
11+
12+
"github.com/stmcginnis/gofish/redfish"
13+
)
14+
15+
var computerSystemBody = `{
16+
"@odata.type": "#ComputerSystem.v1_14_0.ComputerSystem",
17+
"@odata.id": "/redfish/v1/Systems/1",
18+
"Id": "1",
19+
"Name": "System",
20+
"Description": "Description of server",
21+
"Status": {
22+
"State": "Enabled",
23+
"Health": "OK"
24+
},
25+
"SerialNumber": "S514359X4916804",
26+
"PartNumber": "SYS-821GE-200-02-LL014",
27+
"IndicatorLED": "Off",
28+
"LocationIndicatorActive": false,
29+
"SystemType": "Physical",
30+
"BiosVersion": "2.1",
31+
"Manufacturer": "Supermicro",
32+
"Model": "SYS-821GE-TNHR",
33+
"SKU": "0x1D1415D9",
34+
"UUID": "D4216600-C32C-11EE-8000-7CC25586E492",
35+
"ProcessorSummary": {
36+
"Count": 2,
37+
"Model": "Intel(R) Xeon(R) processor",
38+
"Status": {
39+
"State": "Enabled",
40+
"Health": "OK",
41+
"HealthRollup": "OK"
42+
},
43+
"Metrics": {
44+
"@odata.id": "/redfish/v1/Systems/1/ProcessorSummary/ProcessorMetrics"
45+
}
46+
},
47+
"MemorySummary": {
48+
"TotalSystemMemoryGiB": 2048,
49+
"MemoryMirroring": "System",
50+
"Status": {
51+
"State": "Enabled",
52+
"Health": "OK",
53+
"HealthRollup": "OK"
54+
},
55+
"Metrics": {
56+
"@odata.id": "/redfish/v1/Systems/1/MemorySummary/MemoryMetrics"
57+
}
58+
},
59+
"PowerState": "On",
60+
"PowerOnDelaySeconds": 3,
61+
62+
"3:254:1"
63+
],
64+
"PowerOffDelaySeconds": 3,
65+
66+
"3:254:1"
67+
],
68+
"PowerCycleDelaySeconds": 5,
69+
70+
"5:254:1"
71+
],
72+
"Boot": {
73+
"BootSourceOverrideEnabled": "Disabled",
74+
"BootSourceOverrideMode": "UEFI",
75+
"BootSourceOverrideTarget": "Pxe",
76+
77+
"None",
78+
"Pxe",
79+
"Floppy",
80+
"Cd",
81+
"Usb",
82+
"Hdd",
83+
"BiosSetup",
84+
"UsbCd",
85+
"UefiBootNext",
86+
"UefiHttp"
87+
],
88+
"BootOptions": {
89+
"@odata.id": "/redfish/v1/Systems/1/BootOptions"
90+
},
91+
"BootNext": null,
92+
"BootOrder": [
93+
"Boot0003",
94+
"Boot0004",
95+
"Boot0005",
96+
"Boot0006",
97+
"Boot0002",
98+
"Boot0001"
99+
]
100+
},
101+
"GraphicalConsole": {
102+
"ServiceEnabled": true,
103+
"Port": 5900,
104+
"MaxConcurrentSessions": 4,
105+
"ConnectTypesSupported": [
106+
"KVMIP"
107+
]
108+
},
109+
"SerialConsole": {
110+
"MaxConcurrentSessions": 1,
111+
"SSH": {
112+
"ServiceEnabled": true,
113+
"Port": 22,
114+
"SharedWithManagerCLI": true,
115+
"ConsoleEntryCommand": "cd system1/sol1; start",
116+
"HotKeySequenceDisplay": "press <Enter>, <Esc>, and then <T> to terminate session"
117+
},
118+
"IPMI": {
119+
"HotKeySequenceDisplay": "Press ~. - terminate connection",
120+
"ServiceEnabled": true,
121+
"Port": 623
122+
}
123+
},
124+
"VirtualMediaConfig": {
125+
"ServiceEnabled": true,
126+
"Port": 623
127+
},
128+
"BootProgress": {
129+
"LastState": "SystemHardwareInitializationComplete"
130+
},
131+
"Processors": {
132+
"@odata.id": "/redfish/v1/Systems/1/Processors"
133+
},
134+
"Memory": {
135+
"@odata.id": "/redfish/v1/Systems/1/Memory"
136+
},
137+
"EthernetInterfaces": {
138+
"@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces"
139+
},
140+
"NetworkInterfaces": {
141+
"@odata.id": "/redfish/v1/Systems/1/NetworkInterfaces"
142+
},
143+
"SimpleStorage": {
144+
"@odata.id": "/redfish/v1/Systems/1/SimpleStorage"
145+
},
146+
"Storage": {
147+
"@odata.id": "/redfish/v1/Systems/1/Storage"
148+
},
149+
"LogServices": {
150+
"@odata.id": "/redfish/v1/Systems/1/LogServices"
151+
},
152+
"SecureBoot": {
153+
"@odata.id": "/redfish/v1/Systems/1/SecureBoot"
154+
},
155+
"Bios": {
156+
"@odata.id": "/redfish/v1/Systems/1/Bios"
157+
},
158+
"VirtualMedia": {
159+
"@odata.id": "/redfish/v1/Managers/1/VirtualMedia"
160+
},
161+
"Links": {
162+
"Chassis": [
163+
{
164+
"@odata.id": "/redfish/v1/Chassis/1"
165+
}
166+
],
167+
"ManagedBy": [
168+
{
169+
"@odata.id": "/redfish/v1/Managers/1"
170+
}
171+
]
172+
},
173+
"Actions": {
174+
"Oem": {},
175+
"#ComputerSystem.Reset": {
176+
"target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset",
177+
"@Redfish.ActionInfo": "/redfish/v1/Systems/1/ResetActionInfo"
178+
}
179+
},
180+
"Oem": {
181+
"Supermicro": {
182+
"NodeManager": {
183+
"@odata.id": "/redfish/v1/Systems/1/Oem/Supermicro/NodeManager"
184+
},
185+
"FixedBootOrder": {
186+
"@odata.id": "/redfish/v1/Systems/1/Oem/Supermicro/FixedBootOrder"
187+
},
188+
"@odata.type": "#SmcSystemExtensions.v1_0_0.System"
189+
}
190+
},
191+
"@odata.etag": "\"36f059d60095337115952f02709f65d6\""
192+
}`
193+
194+
// TestComputerSystem tests the parsing of ComputerSystem objects.
195+
func TestComputerSystem(t *testing.T) {
196+
var cs redfish.ComputerSystem
197+
err := json.NewDecoder(strings.NewReader(computerSystemBody)).Decode(&cs)
198+
if err != nil {
199+
t.Errorf("Error decoding JSON: %s", err)
200+
}
201+
202+
result, err := FromComputerSystem(&cs)
203+
if err != nil {
204+
t.Errorf("Error converting Redfish ComputerSystem to SMC ComputerSystem: %s", err)
205+
}
206+
207+
if result.ID != "1" {
208+
t.Errorf("Received invalid ID: %s", result.ID)
209+
}
210+
211+
if result.Name != "System" {
212+
t.Errorf("Received invalid name: %s", result.Name)
213+
}
214+
215+
if result.nodeManager != "/redfish/v1/Systems/1/Oem/Supermicro/NodeManager" {
216+
t.Errorf("Invalid node manager link: %s", result.nodeManager)
217+
}
218+
219+
if result.fixedBootOrder != "/redfish/v1/Systems/1/Oem/Supermicro/FixedBootOrder" {
220+
t.Errorf("Invalid fixed boot order link: %s", result.fixedBootOrder)
221+
}
222+
}

oem/smc/fixedbootorder.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
//
4+
5+
package smc
6+
7+
import (
8+
"github.com/stmcginnis/gofish/common"
9+
)
10+
11+
// FixedBootOrder is the fixed boot order information associated with the system.
12+
// The non-OEM ComputerSystem BootOrder property does not support PATCH method
13+
// since X13/H13 platforms Configuring system boot device order should be via
14+
// FixedBootOrder.
15+
// TODO: This is currently read-only in Gofish.
16+
type FixedBootOrder struct {
17+
common.Entity
18+
BootModeSelected string
19+
FixedBootOrder []string
20+
FixedBootOrderDisabledItem []string
21+
UEFINetwork []string
22+
UEFINetworkDisabledItem []string
23+
UEFIHardDisk []string
24+
UEFIAP []string
25+
UEFIAPDisabledItem []string
26+
}
27+
28+
// GetFixedBootOrder will get a FixedBootOrder instance from the service.
29+
func GetFixedBootOrder(c common.Client, uri string) (*FixedBootOrder, error) {
30+
return common.GetObject[FixedBootOrder](c, uri)
31+
}

oem/smc/fixedbootorder_test.go

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
//
4+
5+
package smc
6+
7+
import (
8+
"encoding/json"
9+
"strings"
10+
"testing"
11+
)
12+
13+
var fixedBootOrderBody = `{
14+
"@odata.type": "#SmcFixedBootOrder.v1_0_0.SmcFixedBootOrder",
15+
"@odata.id": "/redfish/v1/Systems/1/Oem/Supermicro/FixedBootOrder",
16+
"Id": "FixedBootOrder",
17+
"Name": "Fixed Boot Order",
18+
"BootModeSelected": "UEFI",
19+
"FixedBootOrder": [
20+
"UEFI CD/DVD",
21+
"UEFI USB CD/DVD",
22+
"UEFI Network:(B83/D0/F0) UEFI PXE IPv4 Intel(R) Ethernet Controller X550 - 905A0839F618",
23+
"UEFI Hard Disk:ubuntu (HDD,Port:900)",
24+
"UEFI USB Hard Disk",
25+
"UEFI USB Key",
26+
"UEFI USB Floppy",
27+
"UEFI USB Lan",
28+
"UEFI AP:UEFI: Built-in EFI Shell"
29+
],
30+
"FixedBootOrderDisabledItem": [
31+
"Disabled"
32+
],
33+
"UEFINetwork": [
34+
"(B83/D0/F0) UEFI PXE IPv4 Intel(R) Ethernet Controller X550 - 905A0839F618",
35+
"(B83/D0/F1) UEFI PXE IPv4 Intel(R) Ethernet Controller X550 - 905A0839F619",
36+
"(B210/D0/F0) UEFI PXE IPv4 Nvidia Network Adapter - 5C:25:73:60:C5:D8 - 5C257360C5D8",
37+
"(B210/D0/F1) UEFI PXE IPv4 Nvidia Network Adapter - 5C:25:73:60:C5:D9 - 5C257360C5D9"
38+
],
39+
"UEFINetworkDisabledItem": [
40+
"Disabled"
41+
],
42+
"UEFIHardDisk": [
43+
"ubuntu (HDD,Port:900)"
44+
],
45+
"UEFIHardDiskDisabledItem": [
46+
"Disabled"
47+
],
48+
"UEFIAP": [
49+
"UEFI: Built-in EFI Shell"
50+
],
51+
"UEFIAPDisabledItem": [
52+
"Disabled"
53+
],
54+
"@odata.etag": "\"120671877241e67076141a0d63fc7c7b\""
55+
}`
56+
57+
// TestFixedBootOrder tests the parsing of FixedBootOrder objects.
58+
func TestFixedBootOrder(t *testing.T) {
59+
var result FixedBootOrder
60+
err := json.NewDecoder(strings.NewReader(fixedBootOrderBody)).Decode(&result)
61+
if err != nil {
62+
t.Errorf("Error decoding JSON: %s", err)
63+
}
64+
65+
if result.ID != "FixedBootOrder" {
66+
t.Errorf("Received invalid ID: %s", result.ID)
67+
}
68+
69+
if result.BootModeSelected != "UEFI" {
70+
t.Errorf("Invalid BootModeSelected: %s", result.BootModeSelected)
71+
}
72+
73+
if len(result.FixedBootOrder) != 9 {
74+
t.Errorf("Expected 9 fixed boot order entries, got %d", len(result.FixedBootOrder))
75+
}
76+
}

0 commit comments

Comments
 (0)