Coverage for nova/scheduler/weights/compute.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-17 15:08 +0000

1# 

2# Licensed under the Apache License, Version 2.0 (the "License"); you may 

3# not use this file except in compliance with the License. You may obtain 

4# a copy of the License at 

5# 

6# http://www.apache.org/licenses/LICENSE-2.0 

7# 

8# Unless required by applicable law or agreed to in writing, software 

9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

11# License for the specific language governing permissions and limitations 

12# under the License. 

13""" 

14BuildFailure Weigher. Weigh hosts by the number of recent failed boot attempts. 

15 

16""" 

17 

18import nova.conf 

19from nova.scheduler import utils 

20from nova.scheduler import weights 

21 

22CONF = nova.conf.CONF 

23 

24 

25class BuildFailureWeigher(weights.BaseHostWeigher): 

26 def weight_multiplier(self, host_state): 

27 """Override the weight multiplier. Note this is negated.""" 

28 return -1 * utils.get_weight_multiplier( 

29 host_state, 'build_failure_weight_multiplier', 

30 CONF.filter_scheduler.build_failure_weight_multiplier) 

31 

32 def _weigh_object(self, host_state, weight_properties): 

33 """Higher weights win. Our multiplier is negative, so reduce our 

34 weight by number of failed builds. 

35 """ 

36 return host_state.failed_builds