[autotest] Only try to get repo from host attribute if not running in chroot

For test running in chroot using test_that, there is no point to get repo from
host attribute.

BUG=chromium:237512,chromium:479842
TEST=local test_that
test_that -b peppy chromeos1-dshi1.cros dummy_PassServer
confirm the log has no entry like:
FAILED RPC CALL: get_hosts {'hostname': 'chromeos1-dshi1.cros'}

also test scheduler and run a test with scheduler

Change-Id: I40c83b8dca1f16a10fe1df1989b93b21f52be2da
Reviewed-on: https://chromium-review.googlesource.com/269784
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Mungyung Ryu <mkryu@google.com>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 19a29ac..7eae278 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -20,6 +20,14 @@
 from autotest_lib.server.cros.dynamic_suite import constants
 from autotest_lib.server.cros.dynamic_suite import job_status
 
+try:
+    from chromite.lib import cros_build_lib
+except ImportError:
+    logging.warn('Unable to import chromite.')
+    # Init the module variable to None. Access to this module can check if it
+    # is not None before making calls.
+    cros_build_lib = None
+
 
 _SHERIFF_JS = global_config.global_config.get_config_value(
     'NOTIFICATIONS', 'sheriffs', default='')
@@ -524,3 +532,16 @@
 
     """
     return os.path.join(tag, execution_subdir)
+
+
+def is_inside_chroot():
+    """Check if the process is running inside chroot.
+
+    This is a wrapper around chromite.lib.cros_build_lib.IsInsideChroot(). The
+    method checks if cros_build_lib can be imported first.
+
+    @return: True if the process is running inside chroot or cros_build_lib
+             cannot be imported.
+
+    """
+    return not cros_build_lib or cros_build_lib.IsInsideChroot()
\ No newline at end of file