Download official & trybot images; treat as local images for tests.

Currently we cannot get md5sums for official & trybot images, which
causes multiple problems:  Crosperf re-images the DUT every time it
runs a test for an image, even if the image is already on the DUT;
if crosperf is running an experiment with multiple official or trybot
images, it can get confused about which results belong to which image;
caching does not work properly without md5sums.

To fix all of these problems, this CL changes Crosperf to download the
official or trybot images into the /tmp directory in the chroot, and from
there it can treat  them as local images (getting md5sums etc).  In order
to download them, it first has to translate the xbuddy syntax (which can
contain aliases such as 'lumpy/dev-latest') into the actual image name
(e.g. lumpy-release/R36-5727.0.0).  This translation is done by a new
script, translate_xbuddy.py, which must be run from the toolchain-utils
directory inside the chroot.

BUG=356279,356474,356476
TEST=Tested with official and trybot images, using both correct
designations and xbuddy aliases; tested with the image missing from
the chroot and with it already in /tmp; tested with and without caching.
Also tested with the experiment file included in the 3 bugs.

Change-Id: I917b5520604b7d4851db2c8123165e81b866da2b
Reviewed-on: https://chrome-internal-review.googlesource.com/159465
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Commit-Queue: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
diff --git a/image_chromeos.py b/image_chromeos.py
index 97d1534..c6b9b02 100755
--- a/image_chromeos.py
+++ b/image_chromeos.py
@@ -176,13 +176,19 @@
 
     real_src_dir = os.path.join(os.path.realpath(options.chromeos_root),
                                 "src")
+    real_chroot_dir = os.path.join(os.path.realpath(options.chromeos_root),
+                                   "chroot")
     if local_image:
       if located_image.find(real_src_dir) != 0:
-        raise Exception("Located image: %s not in chromeos_root: %s" %
-                        (located_image, options.chromeos_root))
-      chroot_image = os.path.join(
-          "..",
-          located_image[len(real_src_dir):].lstrip("/"))
+        if located_image.find(real_chroot_dir) != 0:
+          raise Exception("Located image: %s not in chromeos_root: %s" %
+                          (located_image, options.chromeos_root))
+        else:
+          chroot_image = located_image[len(real_chroot_dir):]
+      else:
+        chroot_image = os.path.join(
+            "..",
+            located_image[len(real_src_dir):].lstrip("/"))
 
     # Check to see if cros flash is in the chroot or not.
     use_cros_flash = CheckForCrosFlash (options.chromeos_root,