@@ -67,8 +67,8 @@ type Links struct {
6767type Power struct {
6868 State string `json:"state,omitempty"`
6969 Mode string `json:"mode,omitempty"`
70- RestorePolicy string `json:"restore_policy"`
71- PowerControlIDs []string `json:"power_control_ids`
70+ RestorePolicy string `json:"restore_policy,omitempty "`
71+ PowerControlIDs []string `json:"power_control_ids,omitempty" `
7272}
7373
7474type InventoryDetail struct {
@@ -265,8 +265,10 @@ func walkSystems(rf_systems []*redfish.ComputerSystem, rf_chassis *redfish.Chass
265265 systems := []InventoryDetail {}
266266 for _ , rf_computersystem := range rf_systems {
267267 var (
268- managerLinks []string
269- chassisLinks []string
268+ managerLinks []string
269+ chassisLinks []string
270+ power * redfish.Power
271+ powercontrolIDs []string
270272 )
271273
272274 // get all of the links to managers
@@ -286,6 +288,20 @@ func walkSystems(rf_systems []*redfish.ComputerSystem, rf_chassis *redfish.Chass
286288
287289 if rf_chassis != nil {
288290 chassisLinks = append (chassisLinks , rf_chassis .ODataID )
291+
292+ // get power-related details from rf_chassis
293+ power , err = rf_chassis .Power ()
294+ if err != nil {
295+ log .Warn ().Err (err ).Str ("id" , rf_computersystem .ID ).
296+ Str ("system" , rf_computersystem .Name ).Msg ("failed to get power-related details from chassis" )
297+ } else {
298+ // extract the power control odata.id resource
299+ if power != nil {
300+ for _ , rf_powercontrol := range power .PowerControl {
301+ powercontrolIDs = append (powercontrolIDs , rf_powercontrol .ODataID )
302+ }
303+ }
304+ }
289305 }
290306
291307 // convert supported reset types to []string
@@ -294,18 +310,6 @@ func walkSystems(rf_systems []*redfish.ComputerSystem, rf_chassis *redfish.Chass
294310 actions = append (actions , string (action ))
295311 }
296312
297- // get power-related details from rf_chassis
298- power , err := rf_chassis .Power ()
299- if err != nil {
300- log .Warn ().Err (err ).Str ("id" , rf_computersystem .ID ).
301- Str ("system" , rf_computersystem .Name ).Msg ("failed to get power-related details from chassis" )
302- }
303- // extract the power control odata.id resource
304- powercontrolIDs := []string {}
305- for _ , rf_powercontrol := range power .PowerControl {
306- powercontrolIDs = append (powercontrolIDs , rf_powercontrol .ODataID )
307- }
308-
309313 // get all of the links to the chassis
310314 system := InventoryDetail {
311315 URI : baseURI + "/redfish/v1/Systems/" + rf_computersystem .ID ,
0 commit comments