[autotest] Getting mixed HQEs and special tasks fail on shard AFE

BUG=chromium:486926
TEST=Prepare shard testing cluster. Run a dummy suite on a DUT
that is sharded, and check if I can get mixed HQEs and special tasks
on the shard AFE.

Change-Id: I66449e07d6f5ae4c5e39ee87d4608b8eae9777f3
Reviewed-on: https://chromium-review.googlesource.com/270342
Reviewed-by: Dan Shi <dshi@chromium.org>
Tested-by: Mungyung Ryu <mkryu@google.com>
Commit-Queue: Mungyung Ryu <mkryu@google.com>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index ececc83..fe166b3 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -346,6 +346,26 @@
         return False
 
 
+def is_puppylab_vm(server):
+    """Check if server is a virtual machine in puppylab.
+
+    In the virtual machine testing environment (i.e., puppylab), each
+    shard VM has a hostname like localhost:<port>.
+
+    @param server: Server name to check.
+
+    @return True if given server is a virtual machine in puppylab.
+
+    """
+    # TODO(mkryu): This is a puppylab specific hack. Please update
+    # this method if you have a better solution.
+    regex = re.compile(r'(.+):\d+')
+    m = regex.match(server)
+    if m:
+        return m.group(1) in _LOCAL_HOST_LIST
+    return False
+
+
 def get_function_arg_value(func, arg_name, args, kwargs):
     """Get the value of the given argument for the function.