Merge "Make flavors is_public option actually work"
This commit is contained in:
@@ -1370,9 +1370,9 @@ def instance_type_get_by_name(context, name):
|
|||||||
return IMPL.instance_type_get_by_name(context, name)
|
return IMPL.instance_type_get_by_name(context, name)
|
||||||
|
|
||||||
|
|
||||||
def instance_type_get_by_flavor_id(context, id):
|
def instance_type_get_by_flavor_id(context, id, read_deleted=None):
|
||||||
"""Get instance type by flavor id."""
|
"""Get instance type by flavor id."""
|
||||||
return IMPL.instance_type_get_by_flavor_id(context, id)
|
return IMPL.instance_type_get_by_flavor_id(context, id, read_deleted)
|
||||||
|
|
||||||
|
|
||||||
def instance_type_destroy(context, name):
|
def instance_type_destroy(context, name):
|
||||||
|
@@ -3824,9 +3824,16 @@ def _dict_with_extra_specs(inst_type_query):
|
|||||||
|
|
||||||
|
|
||||||
def _instance_type_get_query(context, session=None, read_deleted=None):
|
def _instance_type_get_query(context, session=None, read_deleted=None):
|
||||||
return model_query(context, models.InstanceTypes, session=session,
|
query = model_query(context, models.InstanceTypes, session=session,
|
||||||
read_deleted=read_deleted).\
|
read_deleted=read_deleted).\
|
||||||
options(joinedload('extra_specs'))
|
options(joinedload('extra_specs'))
|
||||||
|
if not context.is_admin:
|
||||||
|
the_filter = [models.InstanceTypes.is_public == True]
|
||||||
|
the_filter.extend([
|
||||||
|
models.InstanceTypes.projects.any(project_id=context.project_id)
|
||||||
|
])
|
||||||
|
query = query.filter(or_(*the_filter))
|
||||||
|
return query
|
||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
@@ -3914,9 +3921,9 @@ def instance_type_get_by_name(context, name):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
def instance_type_get_by_flavor_id(context, flavor_id):
|
def instance_type_get_by_flavor_id(context, flavor_id, read_deleted):
|
||||||
"""Returns a dict describing specific flavor_id."""
|
"""Returns a dict describing specific flavor_id."""
|
||||||
result = _instance_type_get_query(context).\
|
result = _instance_type_get_query(context, read_deleted=read_deleted).\
|
||||||
filter_by(flavorid=flavor_id).\
|
filter_by(flavorid=flavor_id).\
|
||||||
first()
|
first()
|
||||||
if not result:
|
if not result:
|
||||||
|
Reference in New Issue
Block a user