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))
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')
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'])))
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'))
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'])
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'])
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'))
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'])