Beispiel #1
0
 def test_get_by_host_and_not_type(self):
     fakes = [self.fake_instance(1), self.fake_instance(2)]
     self.mox.StubOutWithMock(db, "instance_get_all_by_host_and_not_type")
     db.instance_get_all_by_host_and_not_type(self.context, "foo", type_id="bar").AndReturn(fakes)
     self.mox.ReplayAll()
     inst_list = instance.InstanceList.get_by_host_and_not_type(self.context, "foo", "bar")
     for i in range(0, len(fakes)):
         self.assertIsInstance(inst_list.objects[i], instance.Instance)
         self.assertEqual(inst_list.objects[i].uuid, fakes[i]["uuid"])
     self.assertRemotes()
 def test_get_by_host_and_not_type(self):
     fakes = [self.fake_instance(1), self.fake_instance(2)]
     self.mox.StubOutWithMock(db, 'instance_get_all_by_host_and_not_type')
     db.instance_get_all_by_host_and_not_type(
         self.context, 'foo', type_id='bar').AndReturn(fakes)
     self.mox.ReplayAll()
     inst_list = instance.InstanceList.get_by_host_and_not_type(
         self.context, 'foo', 'bar')
     for i in range(0, len(fakes)):
         self.assertIsInstance(inst_list.objects[i], instance.Instance)
         self.assertEqual(inst_list.objects[i].uuid, fakes[i]['uuid'])
     self.assertRemotes()
Beispiel #3
0
 def test_get_by_host_and_not_type(self):
     fakes = [self.fake_instance(1),
              self.fake_instance(2)]
     self.mox.StubOutWithMock(db, 'instance_get_all_by_host_and_not_type')
     db.instance_get_all_by_host_and_not_type(self.context, 'foo',
                                              type_id='bar').AndReturn(
                                                  fakes)
     self.mox.ReplayAll()
     inst_list = instance.InstanceList.get_by_host_and_not_type(
         self.context, 'foo', 'bar')
     for i in range(0, len(fakes)):
         self.assertTrue(isinstance(inst_list.objects[i],
                                    instance.Instance))
         self.assertEqual(inst_list.objects[i].uuid, fakes[i]['uuid'])
     self.assertRemotes()
Beispiel #4
0
 def get_by_host_and_not_type(cls,
                              context,
                              host,
                              type_id=None,
                              expected_attrs=None):
     db_inst_list = db.instance_get_all_by_host_and_not_type(
         context, host, type_id=type_id)
     return _make_instance_list(context, cls(), db_inst_list,
                                expected_attrs)
Beispiel #5
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 then the requested
        type. Return True if all instance types match or if host is empty.
        """

        instance_type = filter_properties.get('instance_type')
        context = filter_properties['context'].elevated()
        instances_other_type = db.instance_get_all_by_host_and_not_type(
            context, host_state.host, instance_type['id'])
        return len(instances_other_type) == 0
Beispiel #6
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 then the requested
        type. Return True if all instance types match or if host is empty.
        """

        instance_type = filter_properties.get('instance_type')
        context = filter_properties['context'].elevated()
        instances_other_type = db.instance_get_all_by_host_and_not_type(
                     context, host_state.host, instance_type['id'])
        return len(instances_other_type) == 0
Beispiel #7
0
 def get_by_host_and_not_type(cls, context, host, type_id=None,
                              expected_attrs=None):
     db_inst_list = db.instance_get_all_by_host_and_not_type(
         context, host, type_id=type_id)
     return _make_instance_list(context, cls(), db_inst_list,
                                expected_attrs)