Merge "Add include_disabled parameter to service_get_all_by_binary"

This commit is contained in:
Jenkins
2016-03-10 14:01:38 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 8 deletions

View File

@@ -141,9 +141,13 @@ def service_get_all_by_topic(context, topic):
return IMPL.service_get_all_by_topic(context, topic)
def service_get_all_by_binary(context, binary):
"""Get all services for a given binary."""
return IMPL.service_get_all_by_binary(context, binary)
def service_get_all_by_binary(context, binary, include_disabled=False):
"""Get services for a given binary.
Includes disabled services if 'include_disabled' parameter is True
"""
return IMPL.service_get_all_by_binary(context, binary,
include_disabled=include_disabled)
def service_get_all_by_host(context, host):

View File

@@ -545,11 +545,12 @@ def service_get_by_host_and_topic(context, host, topic):
@pick_context_manager_reader
def service_get_all_by_binary(context, binary):
return model_query(context, models.Service, read_deleted="no").\
filter_by(disabled=False).\
filter_by(binary=binary).\
all()
def service_get_all_by_binary(context, binary, include_disabled=False):
query = model_query(context, models.Service, read_deleted="no").\
filter_by(binary=binary)
if not include_disabled:
query = query.filter_by(disabled=False)
return query.all()
@pick_context_manager_reader