Esempio n. 1
0
 def test_host_extra_capability_get_all_per_host(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='1', computehost_id='1'))
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='2', computehost_id='1'))
     res = db_api.host_extra_capability_get_all_per_host('1')
     self.assertEqual(2, len(res))
Esempio n. 2
0
 def test_delete_host_extra_capability(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='1'))
     db_api.host_extra_capability_destroy('1')
     self.assertIsNone(db_api.host_extra_capability_get('1'))
     self.assertRaises(db_exceptions.BlazarDBNotFound,
                       db_api.host_extra_capability_destroy, '1')
Esempio n. 3
0
    def test_search_for_hosts_by_extra_capability(self):
        """Create one host and test extra capability queries."""
        # We create a first host, with extra capabilities
        db_api.host_create(_get_fake_host_values(id=1))
        db_api.host_extra_capability_create(
            _get_fake_host_extra_capabilities(computehost_id=1))
        db_api.host_extra_capability_create(
            _get_fake_host_extra_capabilities(
                computehost_id=1,
                name='nic_model',
                value='ACME Model A',
            ))
        # We create a second host, without any extra capabilities
        db_api.host_create(_get_fake_host_values(id=2))

        self.assertEqual(1, len(db_api.host_get_all_by_queries(['vgpu == 2'])))
        self.assertEqual(0, len(db_api.host_get_all_by_queries(['vgpu != 2'])))
        self.assertEqual(
            1,
            len(
                db_api.host_get_all_by_queries(
                    ['cpu_info like %Westmere%', 'vgpu == 2'])))
        self.assertEqual(
            0,
            len(
                db_api.host_get_all_by_queries(
                    ['cpu_info like %wrongcpu%', 'vgpu == 2'])))
        self.assertRaises(db_exceptions.BlazarDBNotFound,
                          db_api.host_get_all_by_queries, ['apples < 2048'])
        self.assertEqual(
            1,
            len(db_api.host_get_all_by_queries(['nic_model == ACME Model A'])))
Esempio n. 4
0
 def test_host_extra_capability_get_all_per_name(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='1', computehost_id='1'))
     res = db_api.host_extra_capability_get_all_per_name('1', 'vgpu')
     self.assertEqual(1, len(res))
     self.assertEqual([],
                      db_api.host_extra_capability_get_all_per_name(
                          '1', 'bad'))
Esempio n. 5
0
 def test_update_host_extra_capability(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='1'))
     db_api.host_extra_capability_update('1', {'capability_value': '2'})
     res = db_api.host_extra_capability_get('1')
     self.assertEqual('2', res['capability_value'])
Esempio n. 6
0
 def test_get_host_extra_capability_per_id(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id='1'))
     result = db_api.host_extra_capability_get('1')
     self.assertEqual('1', result['id'])
Esempio n. 7
0
 def test_create_duplicated_host_extra_capability(self):
     db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id=1))
     self.assertRaises(db_exceptions.BlazarDBDuplicateEntry,
                       db_api.host_extra_capability_create,
                       _get_fake_host_extra_capabilities(id='1'))
Esempio n. 8
0
 def test_create_host_extra_capability(self):
     result = db_api.host_extra_capability_create(
         _get_fake_host_extra_capabilities(id=1))
     self.assertEqual(result['id'], _get_fake_host_values(id='1')['id'])