summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorHans Lindgren <hanlind@kth.se>2013-01-26 15:50:31 +0100
committerHans Lindgren <hanlind@kth.se>2013-01-28 12:01:23 +0100
commit16599c060f2fcc5f43cb8cc831a57afaeca2ad4f (patch)
treec1c1ad9d9422faaef0dc6df675d35aac26f8da23 /nova/db
parent2f97345472a8bafa17c425bccfb7b81b46b8d6d5 (diff)
Refactoring/cleanup of compute and db apis
Refactor db call usage and remove some unused code. Change-Id: I49466f7ab54dd6dbf0fc78bab3d2df44392ba3ee
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py18
-rw-r--r--nova/db/sqlalchemy/api.py39
2 files changed, 0 insertions, 57 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index d8a16c52d..0663c8d9c 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -132,15 +132,6 @@ def service_get_all(context, disabled=None):
return IMPL.service_get_all(context, disabled)
-def service_does_host_exist(context, host_name, include_disabled=False):
- """Returns True if 'host_name' is found in the services table, False
- otherwise
- :param: host_name - the name of the host we want to check if it exists
- :param: include_disabled - Set to True to include hosts from disabled
- services"""
- return IMPL.service_does_host_exist(context, host_name, include_disabled)
-
-
def service_get_all_by_topic(context, topic):
"""Get all services for a given topic."""
return IMPL.service_get_all_by_topic(context, topic)
@@ -159,15 +150,6 @@ def service_get_by_compute_host(context, host):
return IMPL.service_get_by_compute_host(context, host)
-def service_get_all_compute_sorted(context):
- """Get all compute services sorted by instance count.
-
- :returns: a list of (Service, instance_count) tuples.
-
- """
- return IMPL.service_get_all_compute_sorted(context)
-
-
def service_get_by_args(context, host, binary):
"""Get the state of a service by node name and binary."""
return IMPL.service_get_by_args(context, host, binary)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 1980c22ad..5f2333acf 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -397,45 +397,6 @@ def service_get_by_compute_host(context, host):
@require_admin_context
-def _service_get_all_topic_subquery(context, session, topic, subq, label):
- sort_value = getattr(subq.c, label)
- return model_query(context, models.Service,
- func.coalesce(sort_value, 0),
- session=session, read_deleted="no").\
- filter_by(topic=topic).\
- filter_by(disabled=False).\
- outerjoin((subq, models.Service.host == subq.c.host)).\
- order_by(sort_value).\
- all()
-
-
-@require_admin_context
-def service_get_all_compute_sorted(context):
- session = get_session()
- with session.begin():
- # NOTE(vish): The intended query is below
- # SELECT services.*, COALESCE(inst_cores.instance_cores,
- # 0)
- # FROM services LEFT OUTER JOIN
- # (SELECT host, SUM(instances.vcpus) AS instance_cores
- # FROM instances GROUP BY host) AS inst_cores
- # ON services.host = inst_cores.host
- topic = CONF.compute_topic
- label = 'instance_cores'
- subq = model_query(context, models.Instance.host,
- func.sum(models.Instance.vcpus).label(label),
- base_model=models.Instance, session=session,
- read_deleted="no").\
- group_by(models.Instance.host).\
- subquery()
- return _service_get_all_topic_subquery(context,
- session,
- topic,
- subq,
- label)
-
-
-@require_admin_context
def service_get_by_args(context, host, binary):
result = model_query(context, models.Service).\
filter_by(host=host).\