Esempio n. 1
0
    def test_get_weight_multiplier(self):
        host_attr = {'vcpus_total': 4, 'vcpus_used': 6,
                     'cpu_allocation_ratio': 1.0}
        host1 = fakes.FakeHostState('fake-host', 'node', host_attr)

        host1.aggregates = [
            objects.Aggregate(
                id=1,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': 'invalid'},
            )]
        # Get value from default given value if the agg meta is invalid.
        self.assertEqual(
            1.0,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0)
        )

        host1.aggregates = [
            objects.Aggregate(
                id=1,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': '1.9'},
            )]
        # Get value from aggregate metadata
        self.assertEqual(
            1.9,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0)
        )

        host1.aggregates = [
            objects.Aggregate(
                id=1,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': '1.9'}),
            objects.Aggregate(
                id=2,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': '1.8'}),
        ]
        # Get min value from aggregate metadata
        self.assertEqual(
            1.8,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0)
        )
Esempio n. 2
0
    def test_get_weight_multiplier(self):
        host_attr = {
            'vcpus_total': 4,
            'vcpus_used': 6,
            'cpu_allocation_ratio': 1.0
        }
        host1 = fakes.FakeHostState('fake-host', 'node', host_attr)

        host1.aggregates = [
            objects.Aggregate(
                id=1,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': 'invalid'},
            )
        ]
        # Get value from default given value if the agg meta is invalid.
        self.assertEqual(
            1.0,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0))

        host1.aggregates = [
            objects.Aggregate(
                id=1,
                name='foo',
                hosts=['fake-host'],
                metadata={'cpu_weight_multiplier': '1.9'},
            )
        ]
        # Get value from aggregate metadata
        self.assertEqual(
            1.9,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0))

        host1.aggregates = [
            objects.Aggregate(id=1,
                              name='foo',
                              hosts=['fake-host'],
                              metadata={'cpu_weight_multiplier': '1.9'}),
            objects.Aggregate(id=2,
                              name='foo',
                              hosts=['fake-host'],
                              metadata={'cpu_weight_multiplier': '1.8'}),
        ]
        # Get min value from aggregate metadata
        self.assertEqual(
            1.8,
            utils.get_weight_multiplier(host1, 'cpu_weight_multiplier', 1.0))
Esempio n. 3
0
 def weight_multiplier(self, host_state):
     """Override the weight multiplier."""
     return utils.get_weight_multiplier(
         host_state, 'cpu_weight_multiplier',
         CONF.filter_scheduler.cpu_weight_multiplier)
Esempio n. 4
0
 def weight_multiplier(self, host_state):
     """How weighted this weigher should be."""
     return utils.get_weight_multiplier(
         host_state, 'cross_cell_move_weight_multiplier',
         CONF.filter_scheduler.cross_cell_move_weight_multiplier)
Esempio n. 5
0
 def weight_multiplier(self, host_state):
     """Override the weight multiplier. Note this is negated."""
     return -1 * utils.get_weight_multiplier(
         host_state, 'build_failure_weight_multiplier',
         CONF.filter_scheduler.build_failure_weight_multiplier)
 def weight_multiplier(self, host_state):
     """Override the weight multiplier."""
     return utils.get_weight_multiplier(
         host_state, 'io_ops_weight_multiplier',
         CONF.filter_scheduler.io_ops_weight_multiplier)
Esempio n. 7
0
 def weight_multiplier(self, host_state):
     return utils.get_weight_multiplier(
         host_state, 'soft_anti_affinity_weight_multiplier',
         CONF.filter_scheduler.soft_anti_affinity_weight_multiplier)
Esempio n. 8
0
 def weight_multiplier(self, host_state):
     """Override the weight multiplier."""
     return utils.get_weight_multiplier(
         host_state, 'metrics_weight_multiplier',
         CONF.metrics.weight_multiplier)
Esempio n. 9
0
 def weight_multiplier(self, host_state):
     return utils.get_weight_multiplier(
         host_state, 'soft_anti_affinity_weight_multiplier',
         CONF.filter_scheduler.soft_anti_affinity_weight_multiplier)