devserver: pass a cache_user to initialize gsutil.

This CL passes an argument cache_user in gsutil initialization. This
'cache_user' is used to create cache directory for gsutil.

BUG=chromium:698304
TEST=emerge chromite to local moblab DUT, call devserver to provision
it. Ran cros flash ssh://.

Change-Id: Ia5789ce18ac4d87e74ccf4f0bb9db7ec535cdccf
Reviewed-on: https://chromium-review.googlesource.com/457861
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
diff --git a/common_util.py b/common_util.py
index b0092d8..a606d9d 100644
--- a/common_util.py
+++ b/common_util.py
@@ -414,3 +414,26 @@
 def IsInsideChroot():
   """Returns True if we are inside chroot."""
   return os.path.exists('/etc/debian_chroot')
+
+
+def IsRunningOnMoblab():
+  """Returns True if this code is running on a chromiumOS DUT."""
+  cmd = ['cat', '/etc/lsb-release']
+  try:
+    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                            stderr=subprocess.PIPE)
+    cmd_output, cmd_error = proc.communicate()
+
+    if cmd_error:
+      _Log('Error happened while reading lsb-release file: %s',
+           cmd_error.rstrip())
+      return False
+
+    if '_moblab' in cmd_output:
+      return True
+    else:
+      return False
+  except subprocess.CalledProcessError as e:
+    _Log('Error happened while checking whether devserver package is running '
+         'on a DUT: %s\n%s', e, e.output)
+    return False