summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2012-11-01 20:49:43 +0000
committerChris Behrens <cbehrens@codestud.com>2012-11-21 20:19:19 +0000
commitddadc54f640e838d2a29744df27e2d21039b5c10 (patch)
tree4a3aefb97cbf22a2a588409ea4ca8f05026c62be
parent5582d203b77741a005687a87673d9fce11b5ee09 (diff)
downloadnova-ddadc54f640e838d2a29744df27e2d21039b5c10.tar.gz
nova-ddadc54f640e838d2a29744df27e2d21039b5c10.tar.xz
nova-ddadc54f640e838d2a29744df27e2d21039b5c10.zip
Cells: Re-add DB model and calls
Implements blueprint nova-compute-cells Change-Id: I5e254988f3dd17cd1147b6c2d0372e3bb6fe6937
-rw-r--r--nova/db/api.py28
-rw-r--r--nova/db/sqlalchemy/api.py47
-rw-r--r--nova/db/sqlalchemy/models.py28
-rw-r--r--nova/exception.py4
4 files changed, 107 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 37acffaf0..ebad6ffae 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -1300,6 +1300,34 @@ def instance_type_access_remove(context, flavor_id, project_id):
####################
+def cell_create(context, values):
+ """Create a new child Cell entry."""
+ return IMPL.cell_create(context, values)
+
+
+def cell_update(context, cell_id, values):
+ """Update a child Cell entry."""
+ return IMPL.cell_update(context, cell_id, values)
+
+
+def cell_delete(context, cell_id):
+ """Delete a child Cell."""
+ return IMPL.cell_delete(context, cell_id)
+
+
+def cell_get(context, cell_id):
+ """Get a specific child Cell."""
+ return IMPL.cell_get(context, cell_id)
+
+
+def cell_get_all(context):
+ """Get all child Cells."""
+ return IMPL.cell_get_all(context)
+
+
+####################
+
+
def instance_metadata_get(context, instance_uuid):
"""Get all metadata for an instance."""
return IMPL.instance_metadata_get(context, instance_uuid)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e1d44b727..96666079a 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -3732,6 +3732,53 @@ def instance_type_access_remove(context, flavor_id, project_id):
project_id=project_id)
+####################
+
+
+@require_admin_context
+def cell_create(context, values):
+ cell = models.Cell()
+ cell.update(values)
+ cell.save()
+ return cell
+
+
+def _cell_get_by_id_query(context, cell_id, session=None):
+ return model_query(context, models.Cell, session=session).\
+ filter_by(id=cell_id)
+
+
+@require_admin_context
+def cell_update(context, cell_id, values):
+ cell = cell_get(context, cell_id)
+ cell.update(values)
+ cell.save()
+ return cell
+
+
+@require_admin_context
+def cell_delete(context, cell_id):
+ session = get_session()
+ with session.begin():
+ return _cell_get_by_id_query(context, cell_id, session=session).\
+ delete()
+
+
+@require_admin_context
+def cell_get(context, cell_id):
+ result = _cell_get_by_id_query(context, cell_id).first()
+
+ if not result:
+ raise exception.CellNotFound(cell_id=cell_id)
+
+ return result
+
+
+@require_admin_context
+def cell_get_all(context):
+ return model_query(context, models.Cell, read_deleted="no").all()
+
+
########################
# User-provided metadata
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 5716f9ecd..12a1e7e74 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -306,6 +306,10 @@ class Instance(BASE, NovaBase):
# EC2 disable_api_termination
disable_terminate = Column(Boolean(), default=False, nullable=False)
+ # OpenStack compute cell name. This will only be set at the top of
+ # the cells tree and it'll be a full cell name such as 'api!hop1!hop2'
+ cell_name = Column(String(255))
+
class InstanceInfoCache(BASE, NovaBase):
"""
@@ -821,6 +825,30 @@ class InstanceTypeExtraSpecs(BASE, NovaBase):
'InstanceTypeExtraSpecs.deleted == False)')
+class Cell(BASE, NovaBase):
+ """Represents parent and child cells of this cell. Cells can
+ have multiple parents and children, so there could be any number
+ of entries with is_parent=True or False
+ """
+ __tablename__ = 'cells'
+ id = Column(Integer, primary_key=True)
+ # Name here is the 'short name' of a cell. For instance: 'child1'
+ name = Column(String(255))
+ api_url = Column(String(255))
+ # FIXME(comstud): username and password refer to the credentials
+ # used for talking with the AMQP server within a particular cell.
+ # This table needs cleanup to support more generic cells
+ # communication (including via 0mq, for instance)
+ username = Column(String(255))
+ password = Column(String(255))
+ weight_offset = Column(Float(), default=0.0)
+ weight_scale = Column(Float(), default=1.0)
+ is_parent = Column(Boolean())
+ rpc_host = Column(String(255))
+ rpc_port = Column(Integer())
+ rpc_virtual_host = Column(String(255))
+
+
class AggregateHost(BASE, NovaBase):
"""Represents a host that is member of an aggregate."""
__tablename__ = 'aggregate_hosts'
diff --git a/nova/exception.py b/nova/exception.py
index 54b3a17cc..2ba11ac32 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -753,6 +753,10 @@ class FlavorAccessNotFound(NotFound):
"%(project_id) combination.")
+class CellNotFound(NotFound):
+ message = _("Cell %(cell_id)s could not be found.")
+
+
class SchedulerHostFilterNotFound(NotFound):
message = _("Scheduler Host Filter %(filter_name)s could not be found.")