[autotest] Move _cros_build property

BUG=chromium:672348
TEST=None

Change-Id: I12c8b2ccdf7ae1013855339344d80bce707c04f0
Reviewed-on: https://chromium-review.googlesource.com/462657
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/server/cros/dynamic_suite/suite.py b/server/cros/dynamic_suite/suite.py
index 199faed..233abb4 100644
--- a/server/cros/dynamic_suite/suite.py
+++ b/server/cros/dynamic_suite/suite.py
@@ -303,6 +303,7 @@
 
     def __init__(
             self,
+            builds,
             board,
             pool=None,
             ignore_deps=False,
@@ -310,6 +311,7 @@
         """
         Constructor
 
+        @param builds: the builds on which we're running this suite.
         @param board: the board on which we're running this suite.
         @param pool: Specify the pool of machines to use for scheduling
                 purposes.
@@ -321,12 +323,23 @@
         """
         if extra_deps is None:
             extra_deps = []
+        self._builds = builds
         self._board = board
         self._pool = pool
         self._ignore_deps = ignore_deps
         self._extra_deps = extra_deps
 
 
+    @property
+    def cros_build(self):
+        """Return the CrOS build or the first build in the builds dict."""
+        # TODO(ayatane): Note that the builds dict isn't ordered.  I'm not
+        # sure what the implications of this are, but it's probably not a
+        # good thing.
+        return self._builds.get(provision.CROS_VERSION_PREFIX,
+                                self._builds.values()[0])
+
+
     def _create_job_deps(self, test):
         """Create job deps list for a test job.
 
@@ -934,6 +947,7 @@
         self._test_args = test_args
 
         self._job_creator = _SuiteChildJobCreator(
+            builds=builds,
             board=board,
             pool=pool,
             ignore_deps=ignore_deps,
@@ -941,16 +955,6 @@
         )
 
 
-    @property
-    def _cros_build(self):
-        """Return the CrOS build or the first build in the builds dict."""
-        # TODO(ayatane): Note that the builds dict isn't ordered.  I'm not
-        # sure what the implications of this are, but it's probably not a
-        # good thing.
-        return self._builds.get(provision.CROS_VERSION_PREFIX,
-                                self._builds.values()[0])
-
-
     def _create_job(self, test, retry_for=None):
         """
         Thin wrapper around frontend.AFE.create_job().
@@ -967,7 +971,7 @@
         test_obj = self._afe.create_job(
             control_file=test.text,
             name=tools.create_job_name(
-                    self._test_source_build or self._cros_build,
+                    self._test_source_build or self._job_creator.cros_build,
                     self._tag,
                     test.name),
             control_type=test.test_type.capitalize(),
@@ -997,7 +1001,7 @@
         @returns: A keyvals dict for creating the test job.
         """
         keyvals = {
-            constants.JOB_BUILD_KEY: self._cros_build,
+            constants.JOB_BUILD_KEY: self._job_creator.cros_build,
             constants.JOB_SUITE_KEY: self._tag,
             constants.JOB_EXPERIMENTAL_KEY: test.experimental,
             constants.JOB_BUILDS_KEY: self._builds
@@ -1013,7 +1017,7 @@
         # compile an autoserv command line to run in a SSP container using
         # previous builds.
         if (self._test_source_build and
-            (self._cros_build != self._test_source_build or
+            (self._job_creator.cros_build != self._test_source_build or
              len(self._builds) > 1)):
             keyvals[constants.JOB_TEST_SOURCE_BUILD_KEY] = \
                     self._test_source_build
@@ -1349,7 +1353,7 @@
 
         job_views = self._tko.run('get_detailed_test_views',
                                   afe_job_id=result.id)
-        return reporting.TestBug(self._cros_build,
+        return reporting.TestBug(self._job_creator.cros_build,
                 site_utils.get_chrome_version(job_views),
                 self._tag,
                 result)