Finish DB session cleanup
Remove session parameter from: agent_build_get_by_triple() bw_usage_update() They are never called with session parameter Rename aggregate_get_query() -> _aggregate_get_query() because it is private method Enable N309 implement blueprint db-session-cleanup Change-Id: Idd43d230105cb140d8825a251f03a58ea28cce90
This commit is contained in:
parent
58be3dab69
commit
d6a5158e21
@ -4468,10 +4468,8 @@ def agent_build_create(context, values):
|
|||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def agent_build_get_by_triple(context, hypervisor, os, architecture,
|
def agent_build_get_by_triple(context, hypervisor, os, architecture):
|
||||||
session=None):
|
return model_query(context, models.AgentBuild, read_deleted="no").\
|
||||||
return model_query(context, models.AgentBuild, session=session,
|
|
||||||
read_deleted="no").\
|
|
||||||
filter_by(hypervisor=hypervisor).\
|
filter_by(hypervisor=hypervisor).\
|
||||||
filter_by(os=os).\
|
filter_by(os=os).\
|
||||||
filter_by(architecture=architecture).\
|
filter_by(architecture=architecture).\
|
||||||
@ -4528,10 +4526,9 @@ def bw_usage_get_by_uuids(context, uuids, start_period):
|
|||||||
@require_context
|
@require_context
|
||||||
@_retry_on_deadlock
|
@_retry_on_deadlock
|
||||||
def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
|
def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
|
||||||
last_ctr_in, last_ctr_out, last_refreshed=None,
|
last_ctr_in, last_ctr_out, last_refreshed=None):
|
||||||
session=None):
|
|
||||||
if not session:
|
session = get_session()
|
||||||
session = get_session()
|
|
||||||
|
|
||||||
if last_refreshed is None:
|
if last_refreshed is None:
|
||||||
last_refreshed = timeutils.utcnow()
|
last_refreshed = timeutils.utcnow()
|
||||||
@ -4917,9 +4914,8 @@ def aggregate_get_all(context):
|
|||||||
return _aggregate_get_query(context, models.Aggregate).all()
|
return _aggregate_get_query(context, models.Aggregate).all()
|
||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
def _aggregate_metadata_get_query(context, aggregate_id, session=None,
|
||||||
def aggregate_metadata_get_query(context, aggregate_id, session=None,
|
read_deleted="yes"):
|
||||||
read_deleted="yes"):
|
|
||||||
return model_query(context,
|
return model_query(context,
|
||||||
models.AggregateMetadata,
|
models.AggregateMetadata,
|
||||||
read_deleted=read_deleted,
|
read_deleted=read_deleted,
|
||||||
@ -4961,9 +4957,9 @@ def aggregate_metadata_add(context, aggregate_id, metadata, set_delete=False):
|
|||||||
session = get_session()
|
session = get_session()
|
||||||
all_keys = metadata.keys()
|
all_keys = metadata.keys()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = aggregate_metadata_get_query(context, aggregate_id,
|
query = _aggregate_metadata_get_query(context, aggregate_id,
|
||||||
read_deleted='no',
|
read_deleted='no',
|
||||||
session=session)
|
session=session)
|
||||||
if set_delete:
|
if set_delete:
|
||||||
query.filter(~models.AggregateMetadata.key.in_(all_keys)).\
|
query.filter(~models.AggregateMetadata.key.in_(all_keys)).\
|
||||||
soft_delete(synchronize_session=False)
|
soft_delete(synchronize_session=False)
|
||||||
|
2
tox.ini
2
tox.ini
@ -45,7 +45,7 @@ commands = {posargs}
|
|||||||
# H102 Apache 2.0 license header not found
|
# H102 Apache 2.0 license header not found
|
||||||
# H501 Do not use locals() for string formatting
|
# H501 Do not use locals() for string formatting
|
||||||
|
|
||||||
ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H102,H302,H404,F403,H501,F811,F841,N309
|
ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H102,H302,H404,F403,H501,F811,F841
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*plugins/xenserver*,tools
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*plugins/xenserver*,tools
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
|
Loading…
Reference in New Issue
Block a user