コード例 #1
0
    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
コード例 #2
0
ファイル: type_filter.py プロジェクト: hsluoyz/patron
    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
コード例 #3
0
ファイル: test_utils.py プロジェクト: hsluoyz/patron
 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))
コード例 #4
0
ファイル: test_utils.py プロジェクト: 2Exception/patron
 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))