def host_passes(self, host_state, filter_properties): """Dynamically limits hosts to one instance type Return False if host has any instance types other than the requested type. Return True if all instance types match or if host is empty. """ instance_type = filter_properties.get('instance_type') instance_type_id = instance_type['id'] other_types_on_host = utils.other_types_on_host(host_state, instance_type_id) return not other_types_on_host
def host_passes(self, host_state, spec_obj): """Dynamically limits hosts to one instance type Return False if host has any instance types other than the requested type. Return True if all instance types match or if host is empty. """ instance_type = spec_obj.flavor instance_type_id = instance_type.id other_types_on_host = utils.other_types_on_host(host_state, instance_type_id) return not other_types_on_host
def host_passes(self, host_state, filter_properties): """Dynamically limits hosts to one instance type Return False if host has any instance types other than the requested type. Return True if all instance types match or if host is empty. """ instance_type = filter_properties.get('instance_type') instance_type_id = instance_type['id'] other_types_on_host = utils.other_types_on_host( host_state, instance_type_id) return not other_types_on_host
def test_other_types_on_host(self): inst1 = objects.Instance(uuid='aa', instance_type_id=1) host_state = fakes.FakeHostState('host1', 'node1', {}) host_state.instances = {inst1.uuid: inst1} self.assertFalse(utils.other_types_on_host(host_state, 1)) self.assertTrue(utils.other_types_on_host(host_state, 2))