Add ability to reimage firmware

The dynamic suite framework needs to be flexible enough to allow
reimaging of the DUT with either Chrome OS (already supported) or
firmware images. This change allows certain test suites to request
firmware reimaging instead of Chrome OS.

Firmware tarball artifact is now downloaded by the devserver if found
in the build storage bucket. The name of the firmware tarball is fixed
to 'firmware_from_source.tar.bz2', a definition is added to
global_config.ini.

When a DUT is reimaged, a label is created to mark the appropriate
hosts with the Chrome OS version they have installed. This change adds
another label prefix, 'fw-version:' to create labels matching the
firmware version installed on the DUT.

The Reimager class is now a base for two distinct classes, OsReimager
and FwReimager. A few attributes have been added to keep track of
different imaging flows.

The Suite class is now being passed the label prefix so that it
creates proper dependencies to allow to find hosts reimaged with the
appropriate firmware or Chrome OS version to run the tests.

The unittests have been modified to accommodate the underlying module
changes.

The fwupdate control file now allows to be invoked both inside chroot
through run_remote_tests.sh (with parameters coming from the args
dictionary) and outside of chroot with the parameters defined in the
module scope (available through locals()). It also now manages fw
version label removal/assignment.

The fwupdate autotest is now capable of downloading the tarball from
either gs:// or http:// sources.

test_suites/control.faft_lv1 is just a placeholder allowing to debug
the changes, it causes the DUT to be reimaged with the new firmware
and then runs a simple test verifying DUT's firmware sanity.

BUG=chromium-os:37379
TEST=manual

  . verify that unittests still pass:
     $ ./utils/unittest_suite.py  -r server/cros/dynamic_suite
     All passed!

  . verify that ChromeOS reimaging still works as expected:

     $ ./site_utils/run_suite.py -i link-release/R26-3504.0.0 -b link -p link -s smoke

   observe all tests pass and the DUT reimaged with version 3504 also
   observe the proper cros-version: based label created by the AFE
   server and assigned to the DUT host.

  . with servod running locally and the new control file
    (test_suites/control.faft_lv1) copied to the appropriate directory
    on the dev server, ran the following command

     $ ./site_utils/run_suite.py -i link-release/R26-3505.0.0 -b link -p link -s faft_lv1

   observe all tests succeed, and the target come back with the new
   firmware image:

     $ echo $(ssh 192.168.1.4 crossystem fwid)
     Google_Link.3505.0.0

   also observe the proper fw-version: based label created by the AFE
   server and assigned to the DUT host.

Change-Id: I79a7fcc2c4fbb45fdb114630649d60c6e574a619
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40279
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Alex Miller <milleral@chromium.org>
11 files changed