mirror of
https://opendev.org/x/pyghmi
synced 2026-01-11 18:52:33 +00:00
Fix BMC change handling in XCC3
Change-Id: I32e6fea282172690df3f529844ae71ec4a2f466e
This commit is contained in:
@@ -1191,17 +1191,21 @@ class OEMHandler(object):
|
||||
wc.stdheaders['X-Auth-Token'] = self.xauthtoken
|
||||
self.webclient.stdheaders['X-Auth-Token'] = self.xauthtoken
|
||||
|
||||
def _do_web_request(self, url, payload=None, method=None, cache=True):
|
||||
def _do_web_request(self, url, payload=None, method=None, cache=True, etag=None):
|
||||
res = None
|
||||
if cache and payload is None and method is None:
|
||||
res = self._get_cache(url)
|
||||
if res:
|
||||
return res
|
||||
wc = self.webclient.dupe()
|
||||
if etag:
|
||||
wc.stdheaders['If-Match'] = etag
|
||||
res = wc.grab_json_response_with_status(url, payload, method=method)
|
||||
if res[1] == 401 and 'X-Auth-Token' in self.webclient.stdheaders:
|
||||
wc.set_basic_credentials(self.username, self.password)
|
||||
self._get_session_token(wc)
|
||||
if etag:
|
||||
wc.stdheaders['If-Match'] = etag
|
||||
res = wc.grab_json_response_with_status(url, payload,
|
||||
method=method)
|
||||
if res[1] < 200 or res[1] >= 300:
|
||||
|
||||
@@ -950,8 +950,10 @@ class OEMHandler(generic.OEMHandler):
|
||||
acctattribs = {}
|
||||
usbsettings = {}
|
||||
bmchangeset = {}
|
||||
rawchangeset = {}
|
||||
for key in changeset:
|
||||
if isinstance(changeset[key], str):
|
||||
rawchangeset[key] = changeset[key]
|
||||
changeset[key] = {'value': changeset[key]}
|
||||
currval = changeset[key].get('value', None)
|
||||
if key == 'password_complexity':
|
||||
@@ -967,7 +969,10 @@ class OEMHandler(generic.OEMHandler):
|
||||
elif currval and 'enabled'.startswith(currval):
|
||||
currval = 'True'
|
||||
else:
|
||||
currval = int(currval)
|
||||
try:
|
||||
currval = int(currval)
|
||||
except ValueError:
|
||||
pass
|
||||
if key.lower() in self.oemacctmap:
|
||||
if 'Oem' not in acctattribs:
|
||||
acctattribs['Oem'] = {'Lenovo': {}}
|
||||
@@ -984,7 +989,7 @@ class OEMHandler(generic.OEMHandler):
|
||||
'usb_forwarded_ports'):
|
||||
usbsettings[key] = currval
|
||||
else:
|
||||
bmchangeset[key.replace('bmc.', '')] = changeset[key]
|
||||
bmchangeset[key.replace('bmc.', '')] = rawchangeset[key]
|
||||
if acctattribs:
|
||||
self._do_web_request(
|
||||
'/redfish/v1/AccountService', acctattribs, method='PATCH')
|
||||
|
||||
Reference in New Issue
Block a user