From abd805954d29b920f3ebbe47de3283c79a6de8eb Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 1 May 2021 14:28:58 -0500 Subject: [PATCH 1/2] Update gen_script Signed-off-by: Sean McGinnis --- tools/gen_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gen_script.sh b/tools/gen_script.sh index 110c3fd6..4b16a6c5 100755 --- a/tools/gen_script.sh +++ b/tools/gen_script.sh @@ -7,7 +7,7 @@ # Set correct name for python3 executable. Some platforms just call it python # while others call it python3. -PYTHON="python" +PYTHON="python3" # Find the schema document name by going here: # @@ -15,7 +15,7 @@ PYTHON="python" # # Inspect the url for the schema you want - for example, the 2020.1 update # document is "DSP8010_2020.1.zip" on this page. The base name then is: -schemadoc="DSP8010_2020.1" +schemadoc="DSP8010_2020.4" # Check if filename provided on the command line if [[ "$#" -eq 1 ]]; then From fd923eed35969a36e37c75ca8f7266fc6e130eb7 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 1 May 2021 15:00:06 -0500 Subject: [PATCH 2/2] Add chassis drives collection Adds the link to get a chassis drives. Also cleans up a few other calls for related objects. Signed-off-by: Sean McGinnis --- redfish/chassis.go | 52 +++++++++++++++++++++++++++-------------- redfish/chassis_test.go | 7 ++++++ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/redfish/chassis.go b/redfish/chassis.go index 53feeac0..08481c8d 100644 --- a/redfish/chassis.go +++ b/redfish/chassis.go @@ -165,6 +165,12 @@ type Chassis struct { DepthMm float64 // Description provides a description of this resource. Description string + // Drives shall contain an array of links to resources + // of type Drive that are in this chassis. + // Office description is not right, it is a link to a collection. + drives string + // DrivesCount is the number of drives attached to this chassis. + DrivesCount int `json:"Drives@odata.count"` // EnvironmentalClass shall contain the ASHRAE // Environmental Class for this chassis, as defined by ASHRAE Thermal // Guidelines for Data Processing Environments. These classes define @@ -247,6 +253,7 @@ func (chassis *Chassis) UnmarshalJSON(b []byte) error { var t struct { temp + Drives common.Link Thermal common.Link Power common.Link NetworkAdapters common.Link @@ -262,6 +269,8 @@ func (chassis *Chassis) UnmarshalJSON(b []byte) error { *chassis = Chassis(t.temp) // Extract the links to other entities for later + fmt.Printf("+++++ Drives: %v\n", t.Drives) + chassis.drives = string(t.Drives) chassis.thermal = string(t.Thermal) chassis.power = string(t.Power) chassis.networkAdapters = string(t.NetworkAdapters) @@ -335,25 +344,41 @@ func ListReferencedChassis(c common.Client, link string) ([]*Chassis, error) { return result, nil } -// Thermal gets the thermal temperature and cooling information for the chassis -func (chassis *Chassis) Thermal() (*Thermal, error) { - if chassis.thermal == "" { +// Drives gets the drives attached to the storage controllers that this +// resource represents. +func (chassis *Chassis) Drives() ([]*Drive, error) { + if chassis.drives == "" { return nil, nil } - resp, err := chassis.Client.Get(chassis.thermal) + drives, err := common.GetCollection(chassis.Client, chassis.drives) if err != nil { return nil, err } - defer resp.Body.Close() - var thermal Thermal - err = json.NewDecoder(resp.Body).Decode(&thermal) + var result []*Drive + for _, driveLink := range drives.ItemLinks { + drive, err := GetDrive(chassis.Client, driveLink) + if err != nil { + return result, nil + } + result = append(result, drive) + } + return result, nil +} + +// Thermal gets the thermal temperature and cooling information for the chassis +func (chassis *Chassis) Thermal() (*Thermal, error) { + if chassis.thermal == "" { + return nil, nil + } + + thermal, err := GetThermal(chassis.Client, chassis.thermal) if err != nil { return nil, err } - return &thermal, nil + return thermal, nil } // Power gets the power information for the chassis @@ -362,19 +387,12 @@ func (chassis *Chassis) Power() (*Power, error) { return nil, nil } - resp, err := chassis.Client.Get(chassis.power) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - var power Power - err = json.NewDecoder(resp.Body).Decode(&power) + power, err := GetPower(chassis.Client, chassis.power) if err != nil { return nil, err } - return &power, nil + return power, nil } // ComputerSystems returns the collection of systems from this chassis diff --git a/redfish/chassis_test.go b/redfish/chassis_test.go index 3cb96ff3..b679b57f 100644 --- a/redfish/chassis_test.go +++ b/redfish/chassis_test.go @@ -33,6 +33,9 @@ var chassisBody = `{ "State": "Enabled", "Health": "OK" }, + "Drives": { + "@odata.id": "/redfish/v1/Chassis/Chassis-1/Drives" + }, "Thermal": { "@odata.id": "/redfish/v1/Chassis/Chassis-1/Thermal" }, @@ -130,6 +133,10 @@ func TestChassis(t *testing.T) { t.Errorf("Received invalid health status: %s", result.Status.Health) } + if result.drives != "/redfish/v1/Chassis/Chassis-1/Drives" { + t.Errorf("Received invalid drive reference: %s", result.drives) + } + if result.thermal != "/redfish/v1/Chassis/Chassis-1/Thermal" { t.Errorf("Received invalid thermal reference: %s", result.thermal) }