Merge "Remove old flavor_access_get_by_flavor_id db api method"
This commit is contained in:
commit
dd7d5a9c25
|
@ -1547,11 +1547,6 @@ def flavor_destroy(context, flavor_id):
|
|||
"""Delete an instance type."""
|
||||
return IMPL.flavor_destroy(context, flavor_id)
|
||||
|
||||
|
||||
def flavor_access_get_by_flavor_id(context, flavor_id):
|
||||
"""Get flavor access by flavor id."""
|
||||
return IMPL.flavor_access_get_by_flavor_id(context, flavor_id)
|
||||
|
||||
####################
|
||||
|
||||
|
||||
|
|
|
@ -4704,20 +4704,6 @@ def flavor_get_all(context, inactive=False, filters=None,
|
|||
return [_dict_with_extra_specs(i) for i in inst_types]
|
||||
|
||||
|
||||
def _flavor_get_id_from_flavor_query(context, flavor_id):
|
||||
return model_query(context, models.InstanceTypes,
|
||||
(models.InstanceTypes.id,),
|
||||
read_deleted="no").\
|
||||
filter_by(flavorid=flavor_id)
|
||||
|
||||
|
||||
def _flavor_get_id_from_flavor(context, flavor_id):
|
||||
result = _flavor_get_id_from_flavor_query(context, flavor_id).first()
|
||||
if not result:
|
||||
raise exception.FlavorNotFound(flavor_id=flavor_id)
|
||||
return result[0]
|
||||
|
||||
|
||||
@require_context
|
||||
@pick_context_manager_reader
|
||||
def flavor_get(context, id):
|
||||
|
@ -4774,21 +4760,6 @@ def flavor_destroy(context, flavor_id):
|
|||
soft_delete()
|
||||
|
||||
|
||||
def _flavor_access_query(context):
|
||||
return model_query(context, models.InstanceTypeProjects, read_deleted="no")
|
||||
|
||||
|
||||
@pick_context_manager_reader
|
||||
def flavor_access_get_by_flavor_id(context, flavor_id):
|
||||
"""Get flavor access list by flavor id."""
|
||||
instance_type_id_subq = _flavor_get_id_from_flavor_query(context,
|
||||
flavor_id)
|
||||
access_refs = _flavor_access_query(context).\
|
||||
filter_by(instance_type_id=instance_type_id_subq).\
|
||||
all()
|
||||
return access_refs
|
||||
|
||||
|
||||
####################
|
||||
|
||||
|
||||
|
|
|
@ -4058,13 +4058,6 @@ class InstanceTypeTestCase(BaseInstanceTypeTestCase):
|
|||
self._assertEqualObjects(flavor, self._get_base_values(),
|
||||
ignored_keys)
|
||||
|
||||
def test_flavor_create_with_projects(self):
|
||||
projects = ['fake-project1', 'fake-project2']
|
||||
flavor = self._create_flavor({}, projects + ['fake-project2'])
|
||||
access = db.flavor_access_get_by_flavor_id(self.ctxt,
|
||||
flavor['flavorid'])
|
||||
self.assertEqual(projects, [x.project_id for x in access])
|
||||
|
||||
def test_flavor_destroy(self):
|
||||
specs1 = {'a': '1', 'b': '2'}
|
||||
flavor1 = self._create_flavor({'name': 'name1', 'flavorid': 'a1',
|
||||
|
|
Loading…
Reference in New Issue