diff options
author | Matt Spinler <spinler@us.ibm.com> | 2019-10-25 13:49:30 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-10-25 13:55:05 -0500 |
commit | 55a697842f5d474877bb92afec2cd1c0e3100dbd (patch) | |
tree | cbb5915b51b56aab30712ccd0e54df40b328faab /extensions/openpower-pels/registry | |
parent | 5cb5deb6ed44ff670115e249e80bd4c2a3b8c8d7 (diff) | |
download | phosphor-logging-55a697842f5d474877bb92afec2cd1c0e3100dbd.tar.gz phosphor-logging-55a697842f5d474877bb92afec2cd1c0e3100dbd.zip |
PEL: Check duplicate reason codes in registry
Reason codes must be unique for every error until there is a
specific reason for them not to be, so check for that while
validating the message registry JSON file.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I74e0e24e1f129ebf94d25aaf5200b30b256b1307
Diffstat (limited to 'extensions/openpower-pels/registry')
-rwxr-xr-x | extensions/openpower-pels/registry/tools/process_registry.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/openpower-pels/registry/tools/process_registry.py b/extensions/openpower-pels/registry/tools/process_registry.py index 3357c0d..09ad3e0 100755 --- a/extensions/openpower-pels/registry/tools/process_registry.py +++ b/extensions/openpower-pels/registry/tools/process_registry.py @@ -28,6 +28,23 @@ def check_duplicate_names(registry_json): names[entry['Name']] = {} +def check_duplicate_reason_codes(registry_json): + r""" + Check that there aren't any message registry entries with the same + 'ReasonCode' field. + + registry_json: The message registry JSON + """ + + reasonCodes = {} + for entry in registry_json['PELs']: + if entry['SRC']['ReasonCode'] in reasonCodes.keys(): + sys.exit("Found duplicate SRC reason code {}".format( + entry['SRC']['ReasonCode'])) + else: + reasonCodes[entry['SRC']['ReasonCode']] = {} + + def check_component_id(registry_json): r""" Check that the upper byte of the ComponentID field matches the upper byte @@ -108,6 +125,8 @@ def validate_schema(registry, schema): check_duplicate_names(registry_json) + check_duplicate_reason_codes(registry_json) + check_component_id(registry_json) check_message_args(registry_json) |