autotest: Fix bugs in fetching packages for ssp.

This CL fix two things:
1. Only use ssh for devserver-related package download, continue using wget for
other server urls, like 'http://storage.googleapis.com'.
2. When using ssh for downloading, first download it as a temporary file, then
mv it to target file with sudo privilege. This is due to 'sudo' is required in
all operations inside container.

BUG=chromium:666414
TEST=Run 'python ./site_utils/lxc_functional_test.py -s -v' on hot.
Run test dummy_PassServer.ssp on hot.

Change-Id: I98307768923809e02b2e559dec9064d67c686563
Reviewed-on: https://chromium-review.googlesource.com/412427
Commit-Queue: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/site_utils/lxc.py b/site_utils/lxc.py
index 61e47f6..0a8f56a 100644
--- a/site_utils/lxc.py
+++ b/site_utils/lxc.py
@@ -273,7 +273,17 @@
     @param target: Path of the file to save to.
     @param extract_dir: Directory to extract the content of the file to.
     """
-    dev_server.ImageServerBase.download_file(url, target, timeout=300)
+    remote_url = dev_server.DevServer.get_server_url(url)
+    # TODO(xixuan): Better to only ssh to devservers in lab, and continue using
+    # wget for ganeti devservers.
+    if remote_url in dev_server.ImageServerBase.servers():
+        tmp_file = '/tmp/%s' % os.path.basename(target)
+        dev_server.ImageServerBase.download_file(url, tmp_file, timeout=300)
+        utils.run('sudo mv %s %s' % (tmp_file, target))
+    else:
+        utils.run('sudo wget --timeout=300 -nv %s -O %s' % (url, target),
+                  stderr_tee=utils.TEE_TO_LOGS)
+
     utils.run('sudo tar -xvf %s -C %s' % (target, extract_dir))