HewlettPackard / python-redfish-utility

Python-based utility for interacting with devices supporting a Redfish Service
Other
86 stars 41 forks source link

Flashing v1 FWPKGs without `PackageFormat` results in KeyError #79

Closed moonrail closed 1 year ago

moonrail commented 1 year ago

When trying to flash v1 FWPKGs with ilorest >= 4.1.0.0 a KeyError is raised internally and ilorest exits with rc 255:

# ilorest -v flashfwpkg ilo5_210.fwpkg 
iLOrest : RESTful Interface Tool version 4.1.0.0
Copyright (c) 2014-2023 Hewlett Packard Enterprise Development LP
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR: 'PackageFormat'
ILOREST return code: 255

Cause should be these incompatible raw key accesses of PackageFormat:

I could not find the key PackageFormat in any of the older packages.

Here is a v1 FWPKG payload.json:

{
    "Type": "Firmware",
    "UpdatableBy": [ "RuntimeAgent" ],
    "DeviceClass": "2f317b9d-c9e3-4d76-bff6-b9d0d085a952",
    "Devices": {
        "Device": [{
            "DeviceName": "iLO 5",
            "Target": "c0bcf2b9-1141-49af-aab8-c73791f0349c",
            "Version": "2.10",
            "FirmwareImages": [{
                "FileName": "ilo5_210.bin",
                "Order": 1,
                "Type": "Firmware",
                "DirectFlashOk": true,
                "UefiFlashable": false,
                "ResetRequired": false,
                "DelayAfterInstallSec": 120,
                "InstallDurationSec": 240
            }]
        }]
    }
}

Output with 4.0.0.0:

# ilorest -vv flashfwpkg ilo5_210.fwpkg 
iLOrest : RESTful Interface Tool version 4.0.0.0
Copyright (c) 2014-2022 Hewlett Packard Enterprise Development LP
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Uploading firmware: ilo5_210.bin
Successfully checked 'ilo5_210.bin'.
Uploading component ilo5_210.bin
Component ilo5_210.bin uploaded successfully.
[200] The operation completed successfully.
00 hour(s) 09 minute(s) 33 second(s) 
Firmware has successfully been flashed.
iLO will reboot to complete flashing. Session will be terminated.
ILOREST return code: 0

Suggestion: Change xyz['PackageFormat'] to backwards compatible xyz.get('PackageFormat').

Additionally I am not sure, if "ctype A" is only compatible with v2 FWPKGs as with this change v1 FWPKGs (e.g. above mentioned iLO) that are directly flashable without reset and without UEFI, would not be installed correctly.

rajeevkallur commented 1 year ago

Fixed