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]""" args: [host] [service]"""
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
services = db.service_get_all(ctxt) + db.service_get_all(ctxt, True) services = db.service_get_all(ctxt)
if host: if host:
services = [s for s in services if s['host'] == host] services = [s for s in services if s['host'] == host]
if service: if service:

View File

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

View File

@ -196,7 +196,7 @@ class CloudController(object):
def _describe_availability_zones(self, context, **kwargs): def _describe_availability_zones(self, context, **kwargs):
ctxt = context.elevated() 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) disabled_services = db.service_get_all(ctxt, True)
available_zones = [] available_zones = []
for zone in [service.availability_zone for service for zone in [service.availability_zone for service
@ -221,7 +221,7 @@ class CloudController(object):
rv = {'availabilityZoneInfo': [{'zoneName': 'nova', rv = {'availabilityZoneInfo': [{'zoneName': 'nova',
'zoneState': 'available'}]} 'zoneState': 'available'}]}
services = db.service_get_all(context) services = db.service_get_all(context, False)
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
hosts = [] hosts = []
for host in [service['host'] for service in services]: 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) 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.""" """Get all services."""
return IMPL.service_get_all(context, disabled) return IMPL.service_get_all(context, disabled)

View File

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