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
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 @@
             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 @@
 
         check_duplicate_names(registry_json)
 
+        check_duplicate_reason_codes(registry_json)
+
         check_component_id(registry_json)
 
         check_message_args(registry_json)