OLD | NEW |
1 # -*- python -*- | 1 # -*- python -*- |
2 # ex: set syntax=python: | 2 # ex: set syntax=python: |
3 | 3 |
4 # Copyright 2014 The Chromium Authors. All rights reserved. | 4 # Copyright 2014 The Chromium Authors. All rights reserved. |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 import urllib | 8 import urllib |
9 | 9 |
10 from common import cros_chromite | 10 from common import cros_chromite |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return builders | 145 return builders |
146 | 146 |
147 def is_testing_slave(self, slave): | 147 def is_testing_slave(self, slave): |
148 """Returns: True if 'slave' is a testing slave. | 148 """Returns: True if 'slave' is a testing slave. |
149 | 149 |
150 Args: | 150 Args: |
151 slave (BuildSlave): The build slave to test. | 151 slave (BuildSlave): The build slave to test. |
152 """ | 152 """ |
153 return self.testing_slave_pool.is_testing_slave(slave.slavename) | 153 return self.testing_slave_pool.is_testing_slave(slave.slavename) |
154 | 154 |
155 def FilterSlaves(self, chromeos_config, slaves): | 155 def FilterSlaves(self, cbb_config, slaves): |
156 """Filters |slaves| to only contain valid slaves for |chromeos_config|. | 156 """Filters |slaves| to only contain valid slaves for |cbb_config|. |
157 | 157 |
158 Args: | 158 Args: |
159 chromeos_config (ChromiteTarget): The config to filter for. | 159 cbb_config (ChromiteTarget): The config to filter for. |
160 slaves: List of BuildSlave objects to filter to filter. | 160 slaves: List of BuildSlave objects to filter to filter. |
161 """ | 161 """ |
162 if (not chromeos_config or chromeos_config.HasVmTests() or | 162 if (not cbb_config or cbb_config.HasVmTests() or |
163 chromeos_config.HasHwTests()): | 163 cbb_config.HasHwTests()): |
164 slaves = [s for s in slaves if not builder_config.IsGCESlave(s.getName())] | 164 slaves = [s for s in slaves if not builder_config.IsGCESlave(s.getName())] |
165 return slaves | 165 return slaves |
166 | 166 |
167 def __call__(self, slaves, buildrequests): | 167 def __call__(self, slaves, buildrequests): |
168 """Called by master to determine which job to run and which slave to use. | 168 """Called by master to determine which job to run and which slave to use. |
169 | 169 |
170 Build requests may have a 'slaves_request' property (list of strings), | 170 Build requests may have a 'slaves_request' property (list of strings), |
171 established from the try job definition. Such requests allow try jobs to | 171 established from the try job definition. Such requests allow try jobs to |
172 request to be run on specific slaves. | 172 request to be run on specific slaves. |
173 | 173 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 # attached builders with the intention of using more-specialized (fewer | 210 # attached builders with the intention of using more-specialized (fewer |
211 # attached builders) slaves before using generic ones. | 211 # attached builders) slaves before using generic ones. |
212 normal_slaves = [s for s in slaves | 212 normal_slaves = [s for s in slaves |
213 if not self.is_testing_slave(s.slave)] | 213 if not self.is_testing_slave(s.slave)] |
214 | 214 |
215 for br in remaining: | 215 for br in remaining: |
216 normal_slaves.sort(key=lambda s: | 216 normal_slaves.sort(key=lambda s: |
217 -int(builder_config.IsGCESlave(s.slave.slavename))) | 217 -int(builder_config.IsGCESlave(s.slave.slavename))) |
218 | 218 |
219 # Iterate through slaves and choose the appropriate one. | 219 # Iterate through slaves and choose the appropriate one. |
220 chromeos_config_name = br.properties.getProperty('chromeos_config', None) | 220 cbb_config_name = br.properties.getProperty('cbb_config', None) |
221 chromeos_config = configs.get(chromeos_config_name) | 221 cbb_config = configs.get(cbb_config_name) |
222 builder = br.master.status.getBuilder(br.buildername) | 222 builder = br.master.status.getBuilder(br.buildername) |
223 slaves = self.FilterSlaves(chromeos_config, builder.getSlaves()) | 223 slaves = self.FilterSlaves(cbb_config, builder.getSlaves()) |
224 for s in normal_slaves: | 224 for s in normal_slaves: |
225 for builder_slave in slaves: | 225 for builder_slave in slaves: |
226 if s.slave.slavename == builder_slave.getName(): | 226 if s.slave.slavename == builder_slave.getName(): |
227 return s, br | 227 return s, br |
228 return None, None | 228 return None, None |
OLD | NEW |