umpire: ignore resources that are not provided in the factory bundle

A factory bundle may omit some resources(e.g. netboot_firmware).
If the test list does not contain the 'check_image_version' pytest,
then netboot_firmware is not required in the bundle.

BUG=none
TEST=import a bundle without netboot_firmware, the sync_shopfloor test
should run without problems.

Change-Id: I0d499d4f8003af11f4d40cd0f9db5d385f2f203d
Reviewed-on: https://chromium-review.googlesource.com/266470
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Queue: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
diff --git a/py/umpire/client/get_update.py b/py/umpire/client/get_update.py
index 309b413..e84c791 100644
--- a/py/umpire/client/get_update.py
+++ b/py/umpire/client/get_update.py
@@ -196,8 +196,12 @@
     None if there is no netboot firmware update. Otherwise, return the
     downloaded netboot firmware.
   """
-  update_info = GetUpdateForComponents(
-      proxy, ['netboot_firmware'])['netboot_firmware']
+  try:
+    update_info = GetUpdateForComponents(
+        proxy, ['netboot_firmware'])['netboot_firmware']
+  except KeyError:
+    raise RuntimeError('factory bundle does not contain netboot_firmware')
+
   if update_info.needs_update:
     return Download(update_info.url, unzip=False)
   else:
diff --git a/py/umpire/rpc_dut.py b/py/umpire/rpc_dut.py
index 58e3fcd..844791e 100644
--- a/py/umpire/rpc_dut.py
+++ b/py/umpire/rpc_dut.py
@@ -217,6 +217,11 @@
 
       resource_type = (component if not component.startswith('firmware_') else
                        'firmware')
+
+      # Factory bundle does not contain the resource_type e.g. netboot_firmware
+      if resource_type not in resource_map:
+        continue
+
       resource_filename = resource_map[resource_type]
       resource_tag, resource_hash = self._GetResourceTag(
           component, resource_filename)