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:
Boris Pavlovic 2013-08-05 20:05:39 +04:00
parent 58be3dab69
commit d6a5158e21
2 changed files with 11 additions and 15 deletions

View File

@ -4468,10 +4468,8 @@ def agent_build_create(context, values):
@require_admin_context
def agent_build_get_by_triple(context, hypervisor, os, architecture,
session=None):
return model_query(context, models.AgentBuild, session=session,
read_deleted="no").\
def agent_build_get_by_triple(context, hypervisor, os, architecture):
return model_query(context, models.AgentBuild, read_deleted="no").\
filter_by(hypervisor=hypervisor).\
filter_by(os=os).\
filter_by(architecture=architecture).\
@ -4528,9 +4526,8 @@ def bw_usage_get_by_uuids(context, uuids, start_period):
@require_context
@_retry_on_deadlock
def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
last_ctr_in, last_ctr_out, last_refreshed=None,
session=None):
if not session:
last_ctr_in, last_ctr_out, last_refreshed=None):
session = get_session()
if last_refreshed is None:
@ -4917,8 +4914,7 @@ def aggregate_get_all(context):
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"):
return model_query(context,
models.AggregateMetadata,
@ -4961,7 +4957,7 @@ def aggregate_metadata_add(context, aggregate_id, metadata, set_delete=False):
session = get_session()
all_keys = metadata.keys()
with session.begin():
query = aggregate_metadata_get_query(context, aggregate_id,
query = _aggregate_metadata_get_query(context, aggregate_id,
read_deleted='no',
session=session)
if set_delete:

View File

@ -45,7 +45,7 @@ commands = {posargs}
# H102 Apache 2.0 license header not found
# 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
[hacking]