From 91b656d31cac77817db8c865d68471d546903314 Mon Sep 17 00:00:00 2001 From: "Dr. Jens Harbott" Date: Thu, 30 Jan 2025 10:50:24 +0100 Subject: [PATCH] Fix redfish session cache on missing password The redfish_password option is optional, make sure that the SessionCache does not throw an error when it is not set. Closes-Bug: 2097019 Change-Id: Idf792c982a883a4c07ae1dad72e3c54bc73b96a1 --- ironic/drivers/modules/redfish/utils.py | 6 +++++- .../redfish-allow-missing-password-ce4fb161d35a6850.yaml | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/redfish-allow-missing-password-ce4fb161d35a6850.yaml diff --git a/ironic/drivers/modules/redfish/utils.py b/ironic/drivers/modules/redfish/utils.py index d55284cfb8..b00352492e 100644 --- a/ironic/drivers/modules/redfish/utils.py +++ b/ironic/drivers/modules/redfish/utils.py @@ -212,9 +212,13 @@ class SessionCache(object): # include it in the session key. # NOTE(TheJulia): Multiplying the address by 4, to ensure # we meet a minimum of 16 bytes for salt. + # NOTE(frickler): password may be None, make sure we have a str + password = driver_info.get('password') + if not password: + password = '' pw_hash = hashlib.pbkdf2_hmac( 'sha512', - driver_info.get('password').encode('utf-8'), + password.encode('utf-8'), str(driver_info.get('address') * 4).encode('utf-8'), 40) self._driver_info = driver_info # Assemble the session key and append the hashed password to it, diff --git a/releasenotes/notes/redfish-allow-missing-password-ce4fb161d35a6850.yaml b/releasenotes/notes/redfish-allow-missing-password-ce4fb161d35a6850.yaml new file mode 100644 index 0000000000..44e49421d4 --- /dev/null +++ b/releasenotes/notes/redfish-allow-missing-password-ce4fb161d35a6850.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an error within the redfish session cache when no + ``redfish_password`` is specified + `bug 2097019 `_.