hwid: Moves the VPD value check into `gooftool verify_vpd` sub-command.

This CL modifies `gooftool verify_vpd` sub-command so that it
verifies not only values of RO VPD but also values of RW VPD.

This CL also removes the default validation rules for VPD values from
the HWID framework to prevent non-related and duplicated rules
to be evaluated when the HWID framework is generating the HWID string.

And since in general case VPD data is not required when the HWID
framework is generating/verifying the HWID string, this CL also makes
the HWID framework default not to obtain the VPD data, the caller
should explicitly ask the HWID framework to obtain the VPD data if
necessary.

BUG=chromium:796556
TEST=make test

Change-Id: I8f27127415307dda8d05d99b1c4e50cc1a589345
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index eee8ef2..71d2aff 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -140,6 +140,16 @@
     '--hwid', metavar='HWID',
     help='HWID to verify (instead of the currently set HWID of this system).')
 
+_hwid_run_vpd_cmd_arg = CmdArg(
+    '--hwid-run-vpd', action='store_true',
+    help=('Specify the hwid utility to obtain the vpd data by running the '
+          '`vpd` commandline tool.'))
+
+_hwid_vpd_data_file_cmd_arg = CmdArg(
+    '--hwid-vpd-data-file', metavar='FILE.json', type=str, default=None,
+    help=('Specify the hwid utility to obtain the vpd data from the specified '
+          'file.'))
+
 _rma_mode_cmd_arg = CmdArg(
     '--rma_mode', action='store_true',
     help='Enable RMA mode, do not check for deprecated components.')
@@ -463,6 +473,8 @@
          _project_cmd_arg,
          _probe_results_cmd_arg,
          _hwid_cmd_arg,
+         _hwid_run_vpd_cmd_arg,
+         _hwid_vpd_data_file_cmd_arg,
          _rma_mode_cmd_arg,
          _cros_core_cmd_arg,
          _chromebox_cmd_arg,
@@ -656,6 +668,8 @@
          _add_file_cmd_arg,
          _probe_results_cmd_arg,
          _hwid_cmd_arg,
+         _hwid_run_vpd_cmd_arg,
+         _hwid_vpd_data_file_cmd_arg,
          _rma_mode_cmd_arg,
          _cros_core_cmd_arg,
          _chromebox_cmd_arg,
@@ -722,6 +736,8 @@
          _probe_results_cmd_arg,
          _hwdb_path_cmd_arg,
          _hwid_cmd_arg,
+         _hwid_run_vpd_cmd_arg,
+         _hwid_vpd_data_file_cmd_arg,
          _rma_mode_cmd_arg)
 def VerifyHWID(options):
   """A simple wrapper that calls out to HWID utils to verify version 3 HWID.
@@ -735,12 +751,13 @@
     probed_results = yaml.load(file_utils.ReadFile(options.probe_results))
   else:
     probed_results = GetGooftool(options).Probe()
-  vpd = hwid_utils.GetVPD(probed_results)
+
+  vpd = hwid_utils.GetVPDData(options.hwid_run_vpd, options.hwid_vpd_data_file)
 
   event_log.Log('probed_results', probed_results=FilterDict(probed_results))
-  event_log.Log('vpd', vpd=FilterDict(vpd))
+  event_log.Log('vpd', vpd=FilterDict(vpd) if vpd is None else None)
 
-  hwid_utils.VerifyHWID(db, encoded_string, probed_results, vpd,
+  hwid_utils.VerifyHWID(db, encoded_string, probed_results, vpd=vpd,
                         rma_mode=options.rma_mode)
 
   event_log.Log('verified_hwid', hwid=encoded_string)