PEL: Dynamic location code for registry callout

The PEL callout type 'symbolic FRU with trusted location code'
previously had both the symoblic FRU name and the location code
specified in the PEL message registry.  However, there are cases where
the location code is not known until runtime so it cannot be specified
in the registry.

To solve this, create a boolean 'UseInventoryLocCode` key that can be
used in the registry callout entry to specify that the location code to
use for the callout should come from the FRU passed in using the
CALLOUT_INVENTORY_PATH entry in the AdditionalData event log property.
In this case, that FRU will not be added as a normal FRU callout as it
would normally be otherwise.  The registry that uses this must be the
first one in the callout list.

For example:
{
    "Priority": "high",
    "SymbolicFRUTrusted": "air_mover",
    "UseInventoryLocCode": true
},

along with CALLOUT_INVENTORY_PATH=<processor 0 path>

would result in a symbolic FRU callout with the trusted location code
being the processor 0 location code.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iaf65c523803662313f2ad5e197262b9f4e722332
diff --git a/extensions/openpower-pels/registry/schema/schema.json b/extensions/openpower-pels/registry/schema/schema.json
index 50c2d2d..e122db4 100644
--- a/extensions/openpower-pels/registry/schema/schema.json
+++ b/extensions/openpower-pels/registry/schema/schema.json
@@ -454,6 +454,12 @@
             "enum": ["no_vpd_for_fru", "bmc_code"]
         },
 
+        "useInventoryLocCode":
+        {
+            "description": "Used along with SymbolicFRUTrusted to specify that the location code to use with the symbolic FRU is to be taken from the passed in CALLOUT_INVENTORY_PATH callout rather than being specified with LocCode.",
+            "type": "boolean"
+        },
+
         "calloutList":
         {
             "description": "The list of FRU callouts to add to a PEL.  If just LocCode is specified, it is a normal hardware FRU callout.  If Procedure is specified, it is a procedure callout.  If SymbolicFRU or SymbolicFRUTrusted are specified, it is a Symbolic FRU callout.  SymbolicFRUTrusted also requires LocCode.",
@@ -467,7 +473,8 @@
                     "LocCode": {"$ref": "#/definitions/locationCode" },
                     "SymbolicFRU": {"$ref": "#/definitions/symbolicFRU" },
                     "SymbolicFRUTrusted": {"$ref": "#/definitions/symbolicFRUTrusted" },
-                    "Procedure": {"$ref": "#/definitions/procedure" }
+                    "Procedure": {"$ref": "#/definitions/procedure" },
+                    "UseInventoryLocCode": {"$ref": "#/definitions/useInventoryLocCode" }
                 },
                 "additionalProperties": false,
                 "required": ["Priority"],
@@ -480,7 +487,8 @@
                             { "required": ["LocCode"] },
                             { "not": { "required": ["SymbolicFRU"] }},
                             { "not": { "required": ["SymbolicFRUTrusted"] }},
-                            { "not": { "required": ["Procedure"] }}
+                            { "not": { "required": ["Procedure"] }},
+                            { "not": { "required": ["UseInventoryLocCode"] }}
                         ]
                     },
                     {
@@ -489,16 +497,28 @@
                         [
                             { "required": ["SymbolicFRU"] },
                             { "not": { "required": ["SymbolicFRUTrusted"] }},
-                            { "not": { "required": ["Procedure"] }}
+                            { "not": { "required": ["Procedure"] }},
+                            { "not": { "required": ["UseInventoryLocCode"] }}
                         ]
                     },
 
                     {
                         "allOf":
                         [
-                            { "required": ["SymbolicFRUTrusted", "LocationCode"] },
+                            { "required": ["SymbolicFRUTrusted", "LocCode"] },
                             { "not": { "required": ["SymbolicFRU"] }},
-                            { "not": { "required": ["Procedure"] }}
+                            { "not": { "required": ["Procedure"] }},
+                            { "not": { "required": ["UseInventoryLocCode"] }}
+                        ]
+                    },
+
+                    {
+                        "allOf":
+                        [
+                            { "required": ["SymbolicFRUTrusted", "UseInventoryLocCode"] },
+                            { "not": { "required": ["SymbolicFRU"] }},
+                            { "not": { "required": ["Procedure"] }},
+                            { "not": { "required": ["LocCode"] }}
                         ]
                     },
 
@@ -508,7 +528,8 @@
                             { "required": ["Procedure"] },
                             { "not": { "required": ["SymbolicFRU"] }},
                             { "not": { "required": ["SymbolicFRUTrusted"] }},
-                            { "not": { "required": ["LocCode"] }}
+                            { "not": { "required": ["LocCode"] }},
+                            { "not": { "required": ["UseInventoryLocCode"] }}
                         ]
                     }
                 ]