[autotest] Move set_state logic into job_reporter
This logic was contained in scheduler_models.py. The logic is mostly
unchanged.
The biggest change is not repeating all job HQE actions, e.g.
old:
for each hqe:
stuff
for each hqe with the same job:
stuff
new:
for each hqe:
stuff
for each hqe with this job:
stuff
BUG=chromium:748234
TEST=None
Change-Id: I206e45542c46f7dbc3dcf5f08807bb8eca2b7f29
Reviewed-on: https://chromium-review.googlesource.com/767065
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Paul Hobbs <phobbs@google.com>
diff --git a/utils/labellib.py b/utils/labellib.py
index 797cd90..a3ffa2c 100644
--- a/utils/labellib.py
+++ b/utils/labellib.py
@@ -58,6 +58,11 @@
for str_label in str_labels:
self._add_label(str_label)
+ @classmethod
+ def from_host(cls, host):
+ """Create instance using a frontend.afe.models.Host object."""
+ return cls(l.name for l in host.labels.all())
+
def _add_label(self, str_label):
"""Add a label string to the internal map or plain labels list.