diff --git a/nova/db/api.py b/nova/db/api.py index f793bfe03..7cd9e7aed 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -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): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 949f0ba75..346ab360e 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -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