flash: Default version in chrome SDK

In a chrome checkout, when the version is not specified,
attempt to download a remote build with the SDK full version.

Doc at: https://goto.google.com/cros_flash_chrome_defaults

* Implement SDKFetcher.GetCachedFullVersion to get the
full version from the misc cache. Common code in
_LookupMiscCache and GetSDKVersion.
* Allow cros flash to specify non-default cache dir so we
can find the misc cache (this only matters outside the
SDK shell)
* GetDefaultBoard reads $SDK_BOARD in the chrome SDK shell.
* default to remote download in the chrome SDK shell.

BUG=chromium:1070566
TEST=In chrome/chromeos checkout, in chroot, in SDK shell,
in SDK shell with non-default cache dir.
cros flash file:///var/tmp/image.bin --debug
cros flash file:///var/tmp/image.bin betty --debug
cros flash file:///var/tmp/image.bin remote/betty --debug
cros flash file:///var/tmp/image.bin latest --debug
cros flash file:///var/tmp/image.bin R83-12998.0.0 --debug
cros flash file:///var/tmp/image.bin peppy/latest --debug
cros flash file:///var/tmp/image.bin peppy/latest --board betty --debug
cros flash ssh://localhost:9222 --debug

Change-Id: Ie2cedc3701f70b4db469a6d579c91c3210f0c5c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2161520
Tested-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
diff --git a/cli/flash_unittest.py b/cli/flash_unittest.py
index aceea1d..7674d5c 100644
--- a/cli/flash_unittest.py
+++ b/cli/flash_unittest.py
@@ -155,9 +155,9 @@
 
       # Call to download full_payload and stateful. No other calls.
       mock_xbuddy.assert_has_calls(
-          [mock.call('/path/to/image/full_payload', mock.ANY,
+          [mock.call('/path/to/image/full_payload', mock.ANY, mock.ANY,
                      static_dir=flash.DEVSERVER_STATIC_DIR, silent=True),
-           mock.call('/path/to/image/stateful', mock.ANY,
+           mock.call('/path/to/image/stateful', mock.ANY, mock.ANY,
                      static_dir=flash.DEVSERVER_STATIC_DIR, silent=True)])
       self.assertEqual(mock_xbuddy.call_count, 2)
 
@@ -174,9 +174,9 @@
 
       # Call to download full_payload and image. No other calls.
       mock_xbuddy.assert_has_calls(
-          [mock.call('/path/to/image/full_payload', mock.ANY,
+          [mock.call('/path/to/image/full_payload', mock.ANY, mock.ANY,
                      static_dir=flash.DEVSERVER_STATIC_DIR, silent=True),
-           mock.call('/path/to/image', mock.ANY,
+           mock.call('/path/to/image', mock.ANY, mock.ANY,
                      static_dir=flash.DEVSERVER_STATIC_DIR)])
       self.assertEqual(mock_xbuddy.call_count, 2)
 
@@ -294,7 +294,7 @@
     """Test that flash.UsbImagerOperation is called when log level <= NOTICE."""
     expected_cmd = ['dd', 'if=foo', 'of=bar', 'bs=4M', 'iflag=fullblock',
                     'oflag=direct', 'conv=fdatasync']
-    usb_imager = flash.USBImager('dummy_device', 'board', 'foo')
+    usb_imager = flash.USBImager('dummy_device', 'board', 'foo', 'latest')
     run_mock = self.PatchObject(flash.UsbImagerOperation, 'Run')
     self.PatchObject(logging.Logger, 'getEffectiveLevel',
                      return_value=logging.NOTICE)
@@ -309,7 +309,7 @@
     """Test that sudo_run is called when log level > NOTICE."""
     expected_cmd = ['dd', 'if=foo', 'of=bar', 'bs=4M', 'iflag=fullblock',
                     'oflag=direct', 'conv=fdatasync']
-    usb_imager = flash.USBImager('dummy_device', 'board', 'foo')
+    usb_imager = flash.USBImager('dummy_device', 'board', 'foo', 'latest')
     run_mock = self.PatchObject(cros_build_lib, 'sudo_run')
     self.PatchObject(logging.Logger, 'getEffectiveLevel',
                      return_value=logging.WARNING)