コード例 #1
0
ファイル: test_instance.py プロジェクト: ZelinIO/nova
 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()
コード例 #2
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()
コード例 #3
0
ファイル: test_instance.py プロジェクト: slagle/nova
 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()
コード例 #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)
コード例 #5
0
ファイル: type_filter.py プロジェクト: zestrada/nova-cs498cc
    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
コード例 #6
0
ファイル: type_filter.py プロジェクト: B-Rich/nova-1
    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
コード例 #7
0
ファイル: instance.py プロジェクト: DrZaarlon/nova
 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)