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/README.md b/extensions/openpower-pels/registry/README.md
index f1c90f9..89d4578 100644
--- a/extensions/openpower-pels/registry/README.md
+++ b/extensions/openpower-pels/registry/README.md
@@ -377,6 +377,29 @@
 - Symbolic FRU: symbolic_fru
 - Procedure: maint_procedure
 
+#### Symbolic FRU callouts with dynamic trusted location codes
+
+A special case is when one wants to use a symbolic FRU callout with a trusted
+location code, but the location code to use isn\'t known until runtime. This
+means it can\'t be specified using the 'LocCode' key in the registry.
+
+In this case, one should use the 'SymbolicFRUTrusted' key along with the
+'UseInventoryLocCode' key, and then pass in the inventory item that has the
+desired location code using the 'CALLOUT_INVENTORY_PATH' entry inside of the
+AdditionalData property.  The code will then look up the location code for that
+passed in inventory FRU and place it in the symbolic FRU callout.  The normal
+FRU callout with that inventory item will not be created.  The symbolic FRU
+must be the first callout in the registry for this to work.
+
+```
+{
+
+    "Priority": "high",
+    "SymbolicFRUTrusted": "AIR_MOVR",
+    "UseInventoryLocCode": true
+}
+```
+
 ## Modifying and Testing
 
 The general process for adding new entries to the message registry is:
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"] }}
                         ]
                     }
                 ]