Fix "cinder-manage quota check"
When no project id is specified, this fails with: ERROR cinder sqlalchemy.exc.ArgumentError: Textual column expression 'project_id' should be explicitly declared with text('project_id'), or use column('project_id') for more specificity Re-work the query to use column('project_id') to fix this. This moves into the db layer so that cinder-manage doesn't need to directly import sqlalchemy. Closes-Bug: #2077643 Change-Id: I5ff068b01cce8a1ae8747b57b1785325c037cd68
This commit is contained in:
parent
1a0694a833
commit
82be2371fc
@ -401,11 +401,9 @@ class QuotaCommands(object):
|
||||
return []
|
||||
return [project_id]
|
||||
|
||||
projects = db_api.model_query(
|
||||
ctxt,
|
||||
projects = db_api.get_projects(ctxt,
|
||||
models.QuotaUsage,
|
||||
read_deleted="no"
|
||||
).with_entities('project_id').distinct().all()
|
||||
read_deleted="no")
|
||||
project_ids = [row.project_id for row in projects]
|
||||
return project_ids
|
||||
|
||||
|
@ -1982,3 +1982,7 @@ def attachment_specs_update_or_create(context,
|
||||
def remove_temporary_admin_metadata_data_migration(context, max_count):
|
||||
return IMPL.remove_temporary_admin_metadata_data_migration(
|
||||
context, max_count)
|
||||
|
||||
|
||||
def get_projects(context, model, read_deleted="no"):
|
||||
return IMPL.get_projects(context, model, read_deleted=read_deleted)
|
||||
|
@ -8653,3 +8653,8 @@ CALCULATE_COUNT_HELPERS = {
|
||||
'snapshot': (_snaps_get_query, _process_snaps_filters),
|
||||
'backup': (_backups_get_query, _process_backups_filters),
|
||||
}
|
||||
|
||||
|
||||
def get_projects(context, model, read_deleted="no"):
|
||||
return model_query(context, model, read_deleted=read_deleted).\
|
||||
with_entities(sa.Column('project_id')).distinct().all()
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`Bug #2077643 <https://bugs.launchpad.net/cinder/+bug/2077643>`_: Fixed
|
||||
"cinder-manage quota sync" CLI command, which failed with an sqlalchemy
|
||||
error when a project id was not specified.
|
Loading…
Reference in New Issue
Block a user