Clean up get_sample_dut()
BUG=chromium:672348
TEST=None
Change-Id: Ie1970edab5fa028e996c8649ab8d45c2a7c23549
Reviewed-on: https://chromium-review.googlesource.com/418356
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@google.com>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 58fa4fb..a868b02 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -1364,10 +1364,14 @@
"""
if not (dev_server.PREFER_LOCAL_DEVSERVER and pool and board):
return None
-
- hosts = get_host_query(
- ('pool:%s' % pool, 'board:%s' % board), False, False, True, {})
- if not hosts:
+ first_host = get_host_query(
+ multiple_labels=('pool:%s' % pool, 'board:%s' % board),
+ exclude_only_if_needed_labels=False,
+ exclude_atomic_group_hosts=False,
+ valid_only=True,
+ filter_data={},
+ ).first()
+ if first_host is None:
return None
-
- return list(hosts)[0].get_object_dict()['hostname']
+ else:
+ return first_host.hostname