Clean up session in db.sqla.api.migration_* methods
Remove session parameter from migration_get(): Add _migration_get() that contains same logic that old migration_get(), for internal usage, and new migration_get() that doesn't contains session parameter. Remove session parameters from: migration_get_unconfirmed_by_dest_compute() migration_get_in_progress_by_host_and_node() They are never called with session parameter. blueprint db-session-cleanup Change-Id: I3664c78b6aba4c0640903d0f935bc261d5d2129b
This commit is contained in:
parent
5fe218522c
commit
58be3dab69
@ -3807,14 +3807,13 @@ def migration_create(context, values):
|
|||||||
def migration_update(context, id, values):
|
def migration_update(context, id, values):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
migration = migration_get(context, id, session=session)
|
migration = _migration_get(context, id, session=session)
|
||||||
migration.update(values)
|
migration.update(values)
|
||||||
migration.save(session=session)
|
migration.save(session=session)
|
||||||
return migration
|
return migration
|
||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
def _migration_get(context, id, session=None):
|
||||||
def migration_get(context, id, session=None):
|
|
||||||
result = model_query(context, models.Migration, session=session,
|
result = model_query(context, models.Migration, session=session,
|
||||||
read_deleted="yes").\
|
read_deleted="yes").\
|
||||||
filter_by(id=id).\
|
filter_by(id=id).\
|
||||||
@ -3826,6 +3825,11 @@ def migration_get(context, id, session=None):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@require_admin_context
|
||||||
|
def migration_get(context, id):
|
||||||
|
return _migration_get(context, id)
|
||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def migration_get_by_instance_and_status(context, instance_uuid, status):
|
def migration_get_by_instance_and_status(context, instance_uuid, status):
|
||||||
result = model_query(context, models.Migration, read_deleted="yes").\
|
result = model_query(context, models.Migration, read_deleted="yes").\
|
||||||
@ -3842,12 +3846,11 @@ def migration_get_by_instance_and_status(context, instance_uuid, status):
|
|||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
|
def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
|
||||||
dest_compute, session=None):
|
dest_compute):
|
||||||
confirm_window = (timeutils.utcnow() -
|
confirm_window = (timeutils.utcnow() -
|
||||||
datetime.timedelta(seconds=confirm_window))
|
datetime.timedelta(seconds=confirm_window))
|
||||||
|
|
||||||
return model_query(context, models.Migration, session=session,
|
return model_query(context, models.Migration, read_deleted="yes").\
|
||||||
read_deleted="yes").\
|
|
||||||
filter(models.Migration.updated_at <= confirm_window).\
|
filter(models.Migration.updated_at <= confirm_window).\
|
||||||
filter_by(status="finished").\
|
filter_by(status="finished").\
|
||||||
filter_by(dest_compute=dest_compute).\
|
filter_by(dest_compute=dest_compute).\
|
||||||
@ -3855,10 +3858,9 @@ def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
|
|||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def migration_get_in_progress_by_host_and_node(context, host, node,
|
def migration_get_in_progress_by_host_and_node(context, host, node):
|
||||||
session=None):
|
|
||||||
|
|
||||||
return model_query(context, models.Migration, session=session).\
|
return model_query(context, models.Migration).\
|
||||||
filter(or_(and_(models.Migration.source_compute == host,
|
filter(or_(and_(models.Migration.source_compute == host,
|
||||||
models.Migration.source_node == node),
|
models.Migration.source_node == node),
|
||||||
and_(models.Migration.dest_compute == host,
|
and_(models.Migration.dest_compute == host,
|
||||||
|
Loading…
Reference in New Issue
Block a user