Update to use mapped field for Settings Message Severity field

Although the JSON schema does not have this field as enum, its
description says it is defined as Status field from Redfish
specification.
Clarified with DMTF that 'Status section' denotes Health
enum in [1].

MessageRegistry->Message->Severity was introduced in
I9a1735230a8328fd8365e375889c6ab066c3df16 with the same mapping
and it has the same JSON schema as this
Settings->Message->Severity.

This change makes Settings->Message->Severity field of the same type
as MessageRegistry Message Severity field that facilitates
their comparison and error handling.

MessageRegistry's Message and Settings's Message are similar,
but different field types.

[1] https://redfish.dmtf.org/schemas/v1/Resource.json

Change-Id: I1595b1705e2d77f5f4e822ebd87bc6959ee6cf53
Story: 2001791
Task: 19767
This commit is contained in:
Aija Jaunteva 2018-08-14 12:57:18 +03:00 committed by Dmitry Tantsur
parent ec6e6c1df1
commit 0c6623d012
3 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@
from sushy.resources import base
from sushy.resources import common
from sushy.resources import mappings as res_maps
class MessageListField(base.ListField):
@ -29,7 +30,8 @@ class MessageListField(base.ListField):
message = base.Field('Message')
"""Human readable message, if provided"""
severity = base.Field('Severity')
severity = base.MappedField('Severity',
res_maps.SEVERITY_VALUE_MAP)
"""Severity of the error"""
resolution = base.Field('Resolution')

View File

@ -5,7 +5,7 @@
"Messages": [{
"MessageId": "Base.1.0.SettingsFailed",
"Message": "Settings update failed due to invalid value",
"Severity": "High",
"Severity": "Critical",
"Resolution": "Fix the value and try again",
"MessageArgs": [
"arg1"

View File

@ -16,6 +16,7 @@
import json
import mock
from sushy.resources import constants as res_cons
from sushy.resources import settings
from sushy.tests.unit import base
@ -42,7 +43,7 @@ class SettingsFieldTestCase(base.TestCase):
instance.messages[0].message_id)
self.assertEqual('Settings update failed due to invalid value',
instance.messages[0].message)
self.assertEqual('High',
self.assertEqual(res_cons.SEVERITY_CRITICAL,
instance.messages[0].severity)
self.assertEqual('Fix the value and try again',
instance.messages[0].resolution)