[autotest] Fix label detector to handle unreachable hosts.
TEST=Ran the detector.
BUG=chromium:219331
Change-Id: I457077634c78a7dd377e35e672edc27c12b4129d
Reviewed-on: https://chromium-review.googlesource.com/223731
Commit-Queue: Prashanth B <beeps@chromium.org>
Tested-by: Prashanth B <beeps@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index 3333c48..8623c80 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -111,7 +111,6 @@
@returns: A host object which is an instance of the newly created
host class.
"""
-
ssh_user, ssh_pass, ssh_port, ssh_verbosity_flag, ssh_options = \
_get_host_arguments()
diff --git a/site_utils/add_detected_host_labels.py b/site_utils/add_detected_host_labels.py
index 13c1a35..624cf60 100755
--- a/site_utils/add_detected_host_labels.py
+++ b/site_utils/add_detected_host_labels.py
@@ -43,7 +43,7 @@
@return: True on success.
False on failure to fetch labels or to add any individual label.
"""
-
+ host = None
try:
host = hosts.create_host(hostname)
labels = host.get_labels()
@@ -56,7 +56,8 @@
hostname)
return False
finally:
- host.close()
+ if host:
+ host.close()
label_matches = afe.get_labels(name__in=labels)
@@ -107,7 +108,6 @@
hostnames = [m.strip() for m in options.machines.split(',')]
else:
hostnames = afe.get_hostnames()
-
successes = sum(threadpool.imap_unordered(
lambda x: add_missing_labels(afe, x),
hostnames))