regulators: Add device_id to validation tool

Enhance the configuration file validation tool to verify that any
"device_id" properties refer to a valid device ID.  This property exists
in the new phase_fault_detection object.

Add the following new automated tests
* Test where phase_fault_detection object specifies an invalid rule_id
* Test where phase_fault_detection object specifies an invalid device_id

Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I242ced0a2d0c4483d0dd7c4d36781a9f588a7e4f
diff --git a/phosphor-regulators/tools/validate-regulators-config.py b/phosphor-regulators/tools/validate-regulators-config.py
index 125bd0c..f70d9b4 100755
--- a/phosphor-regulators/tools/validate-regulators-config.py
+++ b/phosphor-regulators/tools/validate-regulators-config.py
@@ -102,6 +102,21 @@
             rule_id+'\n')
             handle_validation_error()
 
+def check_device_id_exists(config_json):
+    r"""
+    Check if a device_id property specifies a device ID that does not exist.
+    config_json: Configuration file JSON
+    """
+
+    device_ids = get_values(config_json, 'device_id')
+    valid_device_ids = get_device_ids(config_json)
+    for device_id in device_ids:
+        if device_id not in valid_device_ids:
+            sys.stderr.write("Error: Device ID does not exist.\n"+\
+            "Found device_id value that specifies invalid device ID "+\
+            device_id+'\n')
+            handle_validation_error()
+
 def check_set_device_value_exists(config_json):
     r"""
     Check if a set_device action specifies a device ID that does not exist.
@@ -342,4 +357,6 @@
 
     check_rule_id_exists(config_json)
 
+    check_device_id_exists(config_json)
+
     check_number_of_elements_in_masks(config_json)