From 131d71d7884c3ba9d89879ae674f46b3dec2dba5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 15 Aug 2025 13:30:54 -0400 Subject: [PATCH] Fix redfish account creation Target the collection with a POST if uid does not exist, which is the usual scenario of creating a new user. Change-Id: Ib9b89e7ac6c65e9c48dc7aca656041c8a84eb5cd --- pyghmi/redfish/command.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index b7352f08..9157f4ba 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -415,8 +415,11 @@ class Command(object): Operator, and ReadOnly """ accinfo = self._account_url_info_by_id(uid) - if not accinfo: - raise Exception("Unable to find indicated uid") + if accinfo: + method = 'PATCH' + else: + accinfo = (self._accountserviceurl + '/Accounts', {}) + method = 'POST' if privilege_level.startswith('custom.'): privilege_level = privilege_level.replace('custom.', '') for role in self._validroles: @@ -429,7 +432,7 @@ class Command(object): "Password": password, "RoleId": privilege_level, } - self._do_web_request(accinfo[0], userinfo, method='PATCH', etag=etag) + self._do_web_request(accinfo[0], userinfo, method=method, etag=etag) return True def get_screenshot(self, outfile):