Replaces all references to nova.db.api with nova.db
Fixes bug 881640 Change-Id: Idaa9d175a82f42761e4fbfaf96571671cf44cbcd
This commit is contained in:
@@ -226,7 +226,7 @@ class InstanceTypeFilteringTest(test.TestCase):
|
|||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
|
|
||||||
def assertFilterResults(self, filters, expected):
|
def assertFilterResults(self, filters, expected):
|
||||||
inst_types = db.api.instance_type_get_all(
|
inst_types = db.instance_type_get_all(
|
||||||
self.context, filters=filters)
|
self.context, filters=filters)
|
||||||
inst_names = [i['name'] for i in inst_types]
|
inst_names = [i['name'] for i in inst_types]
|
||||||
self.assertEqual(inst_names, expected)
|
self.assertEqual(inst_names, expected)
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class QuantumTestCaseBase(object):
|
|||||||
project_id = "fake_project1"
|
project_id = "fake_project1"
|
||||||
ctx = context.RequestContext('user1', project_id)
|
ctx = context.RequestContext('user1', project_id)
|
||||||
|
|
||||||
instance_ref = db.api.instance_create(ctx,
|
instance_ref = db.instance_create(ctx,
|
||||||
{"project_id": project_id})
|
{"project_id": project_id})
|
||||||
nw_info = self.net_man.allocate_for_instance(ctx,
|
nw_info = self.net_man.allocate_for_instance(ctx,
|
||||||
instance_id=instance_ref['id'], host="",
|
instance_id=instance_ref['id'], host="",
|
||||||
@@ -246,7 +246,7 @@ class QuantumTestCaseBase(object):
|
|||||||
|
|
||||||
self.net_man.validate_networks(ctx, requested_networks)
|
self.net_man.validate_networks(ctx, requested_networks)
|
||||||
|
|
||||||
instance_ref = db.api.instance_create(ctx,
|
instance_ref = db.instance_create(ctx,
|
||||||
{"project_id": project_id})
|
{"project_id": project_id})
|
||||||
nw_info = self.net_man.allocate_for_instance(ctx,
|
nw_info = self.net_man.allocate_for_instance(ctx,
|
||||||
instance_id=instance_ref['id'], host="",
|
instance_id=instance_ref['id'], host="",
|
||||||
|
|||||||
@@ -35,26 +35,26 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
|
|||||||
vol_extra2="value2",
|
vol_extra2="value2",
|
||||||
vol_extra3=3)
|
vol_extra3=3)
|
||||||
self.vol_type1['extra_specs'] = self.vol_type1_specs
|
self.vol_type1['extra_specs'] = self.vol_type1_specs
|
||||||
ref = db.api.volume_type_create(self.context, self.vol_type1)
|
ref = db.volume_type_create(self.context, self.vol_type1)
|
||||||
self.volume_type1_id = ref.id
|
self.volume_type1_id = ref.id
|
||||||
for k, v in self.vol_type1_specs.iteritems():
|
for k, v in self.vol_type1_specs.iteritems():
|
||||||
self.vol_type1_specs[k] = str(v)
|
self.vol_type1_specs[k] = str(v)
|
||||||
|
|
||||||
self.vol_type2_noextra = dict(name="TEST: Volume type without extra")
|
self.vol_type2_noextra = dict(name="TEST: Volume type without extra")
|
||||||
ref = db.api.volume_type_create(self.context, self.vol_type2_noextra)
|
ref = db.volume_type_create(self.context, self.vol_type2_noextra)
|
||||||
self.vol_type2_id = ref.id
|
self.vol_type2_id = ref.id
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Remove the instance type from the database
|
# Remove the instance type from the database
|
||||||
db.api.volume_type_purge(context.get_admin_context(),
|
db.volume_type_purge(context.get_admin_context(),
|
||||||
self.vol_type1['name'])
|
self.vol_type1['name'])
|
||||||
db.api.volume_type_purge(context.get_admin_context(),
|
db.volume_type_purge(context.get_admin_context(),
|
||||||
self.vol_type2_noextra['name'])
|
self.vol_type2_noextra['name'])
|
||||||
super(VolumeTypeExtraSpecsTestCase, self).tearDown()
|
super(VolumeTypeExtraSpecsTestCase, self).tearDown()
|
||||||
|
|
||||||
def test_volume_type_specs_get(self):
|
def test_volume_type_specs_get(self):
|
||||||
expected_specs = self.vol_type1_specs.copy()
|
expected_specs = self.vol_type1_specs.copy()
|
||||||
actual_specs = db.api.volume_type_extra_specs_get(
|
actual_specs = db.volume_type_extra_specs_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id)
|
self.volume_type1_id)
|
||||||
self.assertEquals(expected_specs, actual_specs)
|
self.assertEquals(expected_specs, actual_specs)
|
||||||
@@ -62,10 +62,10 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
|
|||||||
def test_volume_type_extra_specs_delete(self):
|
def test_volume_type_extra_specs_delete(self):
|
||||||
expected_specs = self.vol_type1_specs.copy()
|
expected_specs = self.vol_type1_specs.copy()
|
||||||
del expected_specs['vol_extra2']
|
del expected_specs['vol_extra2']
|
||||||
db.api.volume_type_extra_specs_delete(context.get_admin_context(),
|
db.volume_type_extra_specs_delete(context.get_admin_context(),
|
||||||
self.volume_type1_id,
|
self.volume_type1_id,
|
||||||
'vol_extra2')
|
'vol_extra2')
|
||||||
actual_specs = db.api.volume_type_extra_specs_get(
|
actual_specs = db.volume_type_extra_specs_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id)
|
self.volume_type1_id)
|
||||||
self.assertEquals(expected_specs, actual_specs)
|
self.assertEquals(expected_specs, actual_specs)
|
||||||
@@ -73,11 +73,11 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
|
|||||||
def test_volume_type_extra_specs_update(self):
|
def test_volume_type_extra_specs_update(self):
|
||||||
expected_specs = self.vol_type1_specs.copy()
|
expected_specs = self.vol_type1_specs.copy()
|
||||||
expected_specs['vol_extra3'] = "4"
|
expected_specs['vol_extra3'] = "4"
|
||||||
db.api.volume_type_extra_specs_update_or_create(
|
db.volume_type_extra_specs_update_or_create(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id,
|
self.volume_type1_id,
|
||||||
dict(vol_extra3=4))
|
dict(vol_extra3=4))
|
||||||
actual_specs = db.api.volume_type_extra_specs_get(
|
actual_specs = db.volume_type_extra_specs_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id)
|
self.volume_type1_id)
|
||||||
self.assertEquals(expected_specs, actual_specs)
|
self.assertEquals(expected_specs, actual_specs)
|
||||||
@@ -86,36 +86,36 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
|
|||||||
expected_specs = self.vol_type1_specs.copy()
|
expected_specs = self.vol_type1_specs.copy()
|
||||||
expected_specs['vol_extra4'] = 'value4'
|
expected_specs['vol_extra4'] = 'value4'
|
||||||
expected_specs['vol_extra5'] = 'value5'
|
expected_specs['vol_extra5'] = 'value5'
|
||||||
db.api.volume_type_extra_specs_update_or_create(
|
db.volume_type_extra_specs_update_or_create(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id,
|
self.volume_type1_id,
|
||||||
dict(vol_extra4="value4",
|
dict(vol_extra4="value4",
|
||||||
vol_extra5="value5"))
|
vol_extra5="value5"))
|
||||||
actual_specs = db.api.volume_type_extra_specs_get(
|
actual_specs = db.volume_type_extra_specs_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id)
|
self.volume_type1_id)
|
||||||
self.assertEquals(expected_specs, actual_specs)
|
self.assertEquals(expected_specs, actual_specs)
|
||||||
|
|
||||||
def test_volume_type_get_with_extra_specs(self):
|
def test_volume_type_get_with_extra_specs(self):
|
||||||
volume_type = db.api.volume_type_get(
|
volume_type = db.volume_type_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.volume_type1_id)
|
self.volume_type1_id)
|
||||||
self.assertEquals(volume_type['extra_specs'],
|
self.assertEquals(volume_type['extra_specs'],
|
||||||
self.vol_type1_specs)
|
self.vol_type1_specs)
|
||||||
|
|
||||||
volume_type = db.api.volume_type_get(
|
volume_type = db.volume_type_get(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.vol_type2_id)
|
self.vol_type2_id)
|
||||||
self.assertEquals(volume_type['extra_specs'], {})
|
self.assertEquals(volume_type['extra_specs'], {})
|
||||||
|
|
||||||
def test_volume_type_get_by_name_with_extra_specs(self):
|
def test_volume_type_get_by_name_with_extra_specs(self):
|
||||||
volume_type = db.api.volume_type_get_by_name(
|
volume_type = db.volume_type_get_by_name(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.vol_type1['name'])
|
self.vol_type1['name'])
|
||||||
self.assertEquals(volume_type['extra_specs'],
|
self.assertEquals(volume_type['extra_specs'],
|
||||||
self.vol_type1_specs)
|
self.vol_type1_specs)
|
||||||
|
|
||||||
volume_type = db.api.volume_type_get_by_name(
|
volume_type = db.volume_type_get_by_name(
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
self.vol_type2_noextra['name'])
|
self.vol_type2_noextra['name'])
|
||||||
self.assertEquals(volume_type['extra_specs'], {})
|
self.assertEquals(volume_type['extra_specs'], {})
|
||||||
@@ -123,7 +123,7 @@ class VolumeTypeExtraSpecsTestCase(test.TestCase):
|
|||||||
def test_volume_type_get_all(self):
|
def test_volume_type_get_all(self):
|
||||||
expected_specs = self.vol_type1_specs.copy()
|
expected_specs = self.vol_type1_specs.copy()
|
||||||
|
|
||||||
types = db.api.volume_type_get_all(context.get_admin_context())
|
types = db.volume_type_get_all(context.get_admin_context())
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
types[self.vol_type1['name']]['extra_specs'], expected_specs)
|
types[self.vol_type1['name']]['extra_specs'], expected_specs)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class VsaTestCase(test.TestCase):
|
|||||||
LOG.debug(_("Test: Emulate DB error. Raise"))
|
LOG.debug(_("Test: Emulate DB error. Raise"))
|
||||||
raise exception.Error
|
raise exception.Error
|
||||||
|
|
||||||
self.stubs.Set(nova.db.api, 'vsa_create', fake_vsa_create)
|
self.stubs.Set(nova.db, 'vsa_create', fake_vsa_create)
|
||||||
self.assertRaises(exception.ApiError,
|
self.assertRaises(exception.ApiError,
|
||||||
self.vsa_api.create, self.context)
|
self.vsa_api.create, self.context)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user