Merge remote branch 'cros/upstream' into autotest-rebase

Merged to upstream trunk@5066, from trunk@4749.

There is no way I could enlist each individual CL from the upstream here since it will blow up the changelist description field.

BUG=
TEST=
Had patched this CL into a fresh cut client to avoid any side effect.
run_remote_test bvt from both emerged location and third_party/autotest/file.

Both test passed!

We should also keep any eye on this to see how it gets propagated into cautotest server.
TBR=dalecurtis

Change-Id: I72f2bc7a9de530178484aea1bfb5ace68bcad029
diff --git a/client/common_lib/base_barrier.py b/client/common_lib/base_barrier.py
index e4de635..e1063a9 100644
--- a/client/common_lib/base_barrier.py
+++ b/client/common_lib/base_barrier.py
@@ -5,6 +5,16 @@
 # default barrier port
 _DEFAULT_PORT = 11922
 
+def get_host_from_id(hostid):
+    # Remove any trailing local identifier following a #.
+    # This allows multiple members per host which is particularly
+    # helpful in testing.
+    if not hostid.startswith('#'):
+        return hostid.split('#')[0]
+    else:
+        raise error.BarrierError(
+            "Invalid Host id: Host Address should be specified")
+
 
 class BarrierAbortError(error.BarrierError):
     """Special BarrierError raised when an explicit abort is requested."""
@@ -159,17 +169,6 @@
         self._waiting = {}  # Maps from hostname -> (client, addr) tuples.
 
 
-    def _get_host_from_id(self, hostid):
-        # Remove any trailing local identifier following a #.
-        # This allows multiple members per host which is particularly
-        # helpful in testing.
-        if not hostid.startswith('#'):
-            return hostid.split('#')[0]
-        else:
-            raise error.BarrierError(
-                    "Invalid Host id: Host Address should be specified")
-
-
     def _update_timeout(self, timeout):
         if timeout is not None and self._start_time is not None:
             self._timeout_secs = (time() - self._start_time) + timeout
@@ -397,14 +396,14 @@
                 remote.settimeout(30)
                 if is_master:
                     # Connect to all slaves.
-                    host = self._get_host_from_id(self._members[self._seen])
+                    host = get_host_from_id(self._members[self._seen])
                     logging.info("calling slave: %s", host)
                     connection = (remote, (host, self._port))
                     remote.connect(connection[1])
                     self._master_welcome(connection)
                 else:
                     # Just connect to the master.
-                    host = self._get_host_from_id(self._masterid)
+                    host = get_host_from_id(self._masterid)
                     logging.info("calling master")
                     connection = (remote, (host, self._port))
                     remote.connect(connection[1])