mirror of
https://opendev.org/x/pyghmi
synced 2025-01-28 11:57:34 +00:00
Carry Redfish error logic to oem
OEM will now relay the generic redfish errors when possible. Change-Id: I31ac6cd9f2949e853e05b55f12d77341cee0d698
This commit is contained in:
parent
771b1781c9
commit
1b58e5ea01
@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import pyghmi.exceptions as exc
|
||||
|
||||
@ -69,7 +70,15 @@ class OEMHandler(object):
|
||||
wc = self.webclient.dupe()
|
||||
res = wc.grab_json_response_with_status(url, payload, method=method)
|
||||
if res[1] < 200 or res[1] >= 300:
|
||||
raise exc.PyghmiException(res[0])
|
||||
try:
|
||||
info = json.loads(res[0])
|
||||
errmsg = [
|
||||
x.get('Message', x['MessageId']) for x in info.get(
|
||||
'error', {}).get('@Message.ExtendedInfo', {})]
|
||||
errmsg = ','.join(errmsg)
|
||||
raise exc.RedfishError(errmsg)
|
||||
except (ValueError, KeyError):
|
||||
raise exc.PyghmiException(str(url) + ":" + res[0])
|
||||
if payload is None and method is None:
|
||||
self._urlcache[url] = {
|
||||
'contents': res[0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user