Made service_get_all()'s disabled parameter default to None. Pass False for enabled services; True for disabled services. Calls to this method have been updated to remain consistent.

This commit is contained in:
Josh Kleinpeter 2011-03-24 18:02:04 +00:00 committed by Tarmac
commit a1cb79c044
5 changed files with 13 additions and 10 deletions

View File

@ -611,7 +611,7 @@ class ServiceCommands(object):
args: [host] [service]"""
ctxt = context.get_admin_context()
now = datetime.datetime.utcnow()
services = db.service_get_all(ctxt) + db.service_get_all(ctxt, True)
services = db.service_get_all(ctxt)
if host:
services = [s for s in services if s['host'] == host]
if service:

View File

@ -304,7 +304,7 @@ class AdminController(object):
* Volume (up, down, None)
* Volume Count
"""
services = db.service_get_all(context)
services = db.service_get_all(context, False)
now = datetime.datetime.utcnow()
hosts = []
rv = []

View File

@ -196,7 +196,7 @@ class CloudController(object):
def _describe_availability_zones(self, context, **kwargs):
ctxt = context.elevated()
enabled_services = db.service_get_all(ctxt)
enabled_services = db.service_get_all(ctxt, False)
disabled_services = db.service_get_all(ctxt, True)
available_zones = []
for zone in [service.availability_zone for service
@ -221,7 +221,7 @@ class CloudController(object):
rv = {'availabilityZoneInfo': [{'zoneName': 'nova',
'zoneState': 'available'}]}
services = db.service_get_all(context)
services = db.service_get_all(context, False)
now = datetime.datetime.utcnow()
hosts = []
for host in [service['host'] for service in services]:

View File

@ -89,7 +89,7 @@ def service_get_by_host_and_topic(context, host, topic):
return IMPL.service_get_by_host_and_topic(context, host, topic)
def service_get_all(context, disabled=False):
def service_get_all(context, disabled=None):
"""Get all services."""
return IMPL.service_get_all(context, disabled)

View File

@ -143,12 +143,15 @@ def service_get(context, service_id, session=None):
@require_admin_context
def service_get_all(context, disabled=False):
def service_get_all(context, disabled=None):
session = get_session()
return session.query(models.Service).\
filter_by(deleted=can_read_deleted(context)).\
filter_by(disabled=disabled).\
all()
query = session.query(models.Service).\
filter_by(deleted=can_read_deleted(context))
if disabled is not None:
query = query.filter_by(disabled=disabled)
return query.all()
@require_admin_context