[autotest] Do not include skylab hosts in inventory emails
BUG=chromium:897338
TEST=local inventory run
Change-Id: I5d7d5e7e2ab737e58418c9a95e36e32ad7b6cf68
Reviewed-on: https://chromium-review.googlesource.com/1326844
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/site_utils/lab_inventory.py b/site_utils/lab_inventory.py
index 8b9b646..0bd7610 100755
--- a/site_utils/lab_inventory.py
+++ b/site_utils/lab_inventory.py
@@ -442,25 +442,24 @@
yield h
+def _is_migrated_to_skylab(afehost):
+ """Return True if the provided frontend.Host has been migrated to skylab."""
+ return afehost.hostname.endswith('-migrated-do-not-use')
+
+
def _eligible_host(afehost):
"""Return whether this host is eligible for monitoring.
- A host is eligible if it has a (unique) 'model' label, it's in
- exactly one pool, and it has no labels from the
- `_EXCLUDED_LABELS` set.
-
@param afehost The host to be tested for eligibility.
"""
- # DUTs without an existing, unique 'model' or 'pool' label
- # aren't meant to exist in the managed inventory; their presence
- # generally indicates an error in the database. Unfortunately
- # such errors have been seen to occur from time to time.
- #
- # The _LabInventory constructor requires hosts to conform to the
- # label restrictions, and may fail if they don't. Failing an
- # inventory run for a single bad entry is the wrong thing, so we
- # ignore the problem children here, to keep them out of the
- # inventory.
+ if _is_migrated_to_skylab(afehost):
+ return False
+
+ # DUTs without an existing, unique 'model' or 'pool' label aren't meant to
+ # exist in the managed inventory; their presence generally indicates an
+ # error in the database. The _LabInventory constructor requires hosts to
+ # conform to the label restrictions. Failing an inventory run for a single
+ # bad entry is wrong, so we ignore these hosts.
models = [l for l in afehost.labels
if l.startswith(constants.Labels.MODEL_PREFIX)]
pools = [l for l in afehost.labels