[autotest] Add a moblab_config to override config value in global config when running in moblab.

The config value set in moblab_config.ini will override values in global
config only when running in moblab. Shadow config values can override
what's set in moblab config.

The config file can be used to disable particular function of autotest that
can be used in test lab but not moblab.

Also fix a bug in server management.

BUG=chromium:377210
TEST=unittest, local autoest setup to confirm shadow config not affected.
DEPLOY=apache

Change-Id: If199ba34f0047776ca8915a445b0d4fe5716e716
Reviewed-on: https://chromium-review.googlesource.com/244170
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index 352ee43..b3a0b3a 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -11,7 +11,10 @@
 import urllib2
 import uuid
 
-from autotest_lib.client.common_lib import base_utils, error, global_config
+from autotest_lib.client.common_lib import base_utils
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.common_lib import global_config
+from autotest_lib.client.common_lib import lsbrelease_utils
 from autotest_lib.client.cros import constants
 
 
@@ -109,52 +112,6 @@
     return None
 
 
-def _lsbrelease_search(regex, group_id=0):
-    """Searches /etc/lsb-release for a regex match.
-
-    @param regex: Regex to match.
-    @param group_id: The group in the regex we are searching for.
-                     Default is group 0.
-
-    @returns the string in the specified group if there is a match or None if
-             not found.
-
-    @raises IOError if /etc/lsb-release can not be accessed.
-    """
-    with open(constants.LSB_RELEASE) as lsb_release_file:
-        for line in lsb_release_file:
-            m = re.match(regex, line)
-            if m:
-                return m.group(group_id)
-    return None
-
-
-def get_current_board():
-    """Return the current board name.
-
-    @return current board name, e.g "lumpy", None on fail.
-    """
-    return _lsbrelease_search(r'^CHROMEOS_RELEASE_BOARD=(.+)$', group_id=1)
-
-
-def get_chromeos_release_version():
-    """
-    @return chromeos version in device under test as string. None on fail.
-    """
-    return _lsbrelease_search(r'^CHROMEOS_RELEASE_VERSION=(.+)$', group_id=1)
-
-
-def is_moblab():
-    """Return if we are running on a Moblab system or not.
-
-    @return the board string if this is a Moblab device or None if it is not.
-    """
-    try:
-        return _lsbrelease_search(r'.*moblab')
-    except IOError as e:
-        logging.error('Unable to determine if this is a moblab system: %s', e)
-
-
 def get_interface_mac_address(interface):
     """Return the MAC address of a given interface.
 
@@ -179,7 +136,7 @@
 
     @returns gsuri to offload test results to.
     """
-    if not is_moblab():
+    if not lsbrelease_utils.is_moblab():
         return DEFAULT_OFFLOAD_GSURI
     moblab_id_filepath = '/home/moblab/.moblab_id'
     if os.path.exists(moblab_id_filepath):