summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorIlya Alekseyev <ialekseev@griddynamics.com>2011-01-12 11:34:16 +0000
committerTarmac <>2011-01-12 11:34:16 +0000
commit3d57735caf78fd421da6e660c4d56c635706fa7d (patch)
treeaf5f18e8719efd3f636a104eef6f4f61dd79cb70 /nova/db
parent5227bfc76657a5af08fc47d3544bf6b06b66e8bf (diff)
parentb94f3a6cce3a49853c2426b87740fc467a4a787b (diff)
downloadnova-3d57735caf78fd421da6e660c4d56c635706fa7d.tar.gz
nova-3d57735caf78fd421da6e660c4d56c635706fa7d.tar.xz
nova-3d57735caf78fd421da6e660c4d56c635706fa7d.zip
Added support of availability zones for compute.
models.Service got additional field availability_zone and was created ZoneScheduler that make decisions based on this field. Also replaced fake 'nova' zone in EC2 cloud api.
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py13
-rw-r--r--nova/db/sqlalchemy/api.py17
-rw-r--r--nova/db/sqlalchemy/models.py1
3 files changed, 23 insertions, 8 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index cf84157bc..1f81ef145 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -81,16 +81,21 @@ def service_get(context, service_id):
return IMPL.service_get(context, service_id)
-def service_get_all(context):
- """Get a list of all services on any machine on any topic of any type"""
- return IMPL.service_get_all(context)
+def service_get_all(context, disabled=False):
+ """Get all service."""
+ return IMPL.service_get_all(context, None, disabled)
def service_get_all_by_topic(context, topic):
- """Get all compute services for a given topic."""
+ """Get all services for a given topic."""
return IMPL.service_get_all_by_topic(context, topic)
+def service_get_all_by_host(context, host):
+ """Get all services for a given host."""
+ return IMPL.service_get_all_by_host(context, host)
+
+
def service_get_all_compute_sorted(context):
"""Get all compute services sorted by instance count.
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 4561fa219..2e4f8fc39 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -135,14 +135,14 @@ def service_get(context, service_id, session=None):
@require_admin_context
-def service_get_all(context, session=None):
+def service_get_all(context, session=None, disabled=False):
if not session:
session = get_session()
result = session.query(models.Service).\
- filter_by(deleted=can_read_deleted(context)).\
- all()
-
+ filter_by(deleted=can_read_deleted(context)).\
+ filter_by(disabled=disabled).\
+ all()
return result
@@ -157,6 +157,15 @@ def service_get_all_by_topic(context, topic):
@require_admin_context
+def service_get_all_by_host(context, host):
+ session = get_session()
+ return session.query(models.Service).\
+ filter_by(deleted=False).\
+ filter_by(host=host).\
+ all()
+
+
+@require_admin_context
def _service_get_all_topic_subquery(context, session, topic, subq, label):
sort_value = getattr(subq.c, label)
return session.query(models.Service, func.coalesce(sort_value, 0)).\
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 2a966448c..1dc46fe78 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -149,6 +149,7 @@ class Service(BASE, NovaBase):
topic = Column(String(255))
report_count = Column(Integer, nullable=False, default=0)
disabled = Column(Boolean, default=False)
+ availability_zone = Column(String(255), default='nova')
class Certificate(BASE, NovaBase):