summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2012-02-28 08:20:25 +0000
committerChris Behrens <cbehrens@codestud.com>2012-02-28 19:08:47 +0000
commit78df2115035cba78c9a3e31d23abe04a8d497fb0 (patch)
tree1c4e065a9c7d4ef6a775bcebee1c74637071a89a /nova
parent9d6d72deb0b9241b924909e86ec9a54aacda4bf4 (diff)
downloadnova-78df2115035cba78c9a3e31d23abe04a8d497fb0.tar.gz
Rename zones table to cells and Instance.zone_name to cell_name
Vish made an executive decision to use the term 'Cell' to refer to the former 'Zone'. :) This fixes up the core code required for the future Cells branch. Change-Id: Iff0fb01f0c2862a646bfb2d3fd4e218f1d2b7a93
Diffstat (limited to 'nova')
-rw-r--r--nova/db/api.py30
-rw-r--r--nova/db/sqlalchemy/api.py40
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py35
-rw-r--r--nova/db/sqlalchemy/models.py10
-rw-r--r--nova/exception.py6
5 files changed, 78 insertions, 43 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index cba0e7456e..bf94747df0 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -1448,29 +1448,29 @@ def instance_type_destroy(context, name):
####################
-def zone_create(context, values):
- """Create a new child Zone entry."""
- return IMPL.zone_create(context, values)
+def cell_create(context, values):
+ """Create a new child Cell entry."""
+ return IMPL.cell_create(context, values)
-def zone_update(context, zone_id, values):
- """Update a child Zone entry."""
- return IMPL.zone_update(context, zone_id, values)
+def cell_update(context, cell_id, values):
+ """Update a child Cell entry."""
+ return IMPL.cell_update(context, cell_id, values)
-def zone_delete(context, zone_id):
- """Delete a child Zone."""
- return IMPL.zone_delete(context, zone_id)
+def cell_delete(context, cell_id):
+ """Delete a child Cell."""
+ return IMPL.cell_delete(context, cell_id)
-def zone_get(context, zone_id):
- """Get a specific child Zone."""
- return IMPL.zone_get(context, zone_id)
+def cell_get(context, cell_id):
+ """Get a specific child Cell."""
+ return IMPL.cell_get(context, cell_id)
-def zone_get_all(context):
- """Get all child Zones."""
- return IMPL.zone_get_all(context)
+def cell_get_all(context):
+ """Get all child Cells."""
+ return IMPL.cell_get_all(context)
####################
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 6496ab7b99..ba3c12b41e 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -3539,47 +3539,47 @@ def instance_type_destroy(context, name):
@require_admin_context
-def zone_create(context, values):
- zone = models.Zone()
- zone.update(values)
- zone.save()
- return zone
+def cell_create(context, values):
+ cell = models.Cell()
+ cell.update(values)
+ cell.save()
+ return cell
-def _zone_get_by_id_query(context, zone_id, session=None):
- return model_query(context, models.Zone, session=session).\
- filter_by(id=zone_id)
+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 zone_update(context, zone_id, values):
- zone = zone_get(context, zone_id)
- zone.update(values)
- zone.save()
- return zone
+def cell_update(context, cell_id, values):
+ cell = cell_get(context, cell_id)
+ cell.update(values)
+ cell.save()
+ return cell
@require_admin_context
-def zone_delete(context, zone_id):
+def cell_delete(context, cell_id):
session = get_session()
with session.begin():
- _zone_get_by_id_query(context, zone_id, session=session).\
+ _cell_get_by_id_query(context, cell_id, session=session).\
delete()
@require_admin_context
-def zone_get(context, zone_id):
- result = _zone_get_by_id_query(context, zone_id).first()
+def cell_get(context, cell_id):
+ result = _cell_get_by_id_query(context, cell_id).first()
if not result:
- raise exception.ZoneNotFound(zone_id=zone_id)
+ raise exception.CellNotFound(cell_id=cell_id)
return result
@require_admin_context
-def zone_get_all(context):
- return model_query(context, models.Zone, read_deleted="no").all()
+def cell_get_all(context):
+ return model_query(context, models.Cell, read_deleted="no").all()
####################
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py b/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py
new file mode 100644
index 0000000000..79e99503af
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py
@@ -0,0 +1,35 @@
+# Copyright 2012 OpenStack LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from sqlalchemy import MetaData, Table
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+ instances = Table('instances', meta, autoload=True)
+ zone_name = instances.c.zone_name
+ zone_name.alter(name='cell_name')
+ zones = Table('zones', meta, autoload=True)
+ zones.rename('cells')
+
+
+def downgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+ instances = Table('instances', meta, autoload=True)
+ cell_name = instances.c.cell_name
+ cell_name.alter(name='zone_name')
+ cells = Table('cells', meta, autoload=True)
+ cells.rename('zones')
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 7f70a5d556..b15cece8d2 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -278,8 +278,8 @@ class Instance(BASE, NovaBase):
# EC2 disable_api_termination
disable_terminate = Column(Boolean(), default=False, nullable=False)
- # Openstack zone name
- zone_name = Column(String(255))
+ # Openstack compute cell name
+ cell_name = Column(String(255))
class InstanceInfoCache(BASE, NovaBase):
@@ -870,9 +870,9 @@ class InstanceTypeExtraSpecs(BASE, NovaBase):
'InstanceTypeExtraSpecs.deleted == False)')
-class Zone(BASE, NovaBase):
- """Represents a child zone of this zone."""
- __tablename__ = 'zones'
+class Cell(BASE, NovaBase):
+ """Represents parent and child cells of this cell."""
+ __tablename__ = 'cells'
id = Column(Integer, primary_key=True)
name = Column(String(255))
api_url = Column(String(255))
diff --git a/nova/exception.py b/nova/exception.py
index e1caf28fe9..4de0f65d1b 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -748,8 +748,8 @@ class FlavorNotFound(NotFound):
message = _("Flavor %(flavor_id)s could not be found.")
-class ZoneNotFound(NotFound):
- message = _("Zone %(zone_id)s could not be found.")
+class CellNotFound(NotFound):
+ message = _("Cell %(cell_id)s could not be found.")
class SchedulerHostFilterNotFound(NotFound):
@@ -1006,4 +1006,4 @@ class InstanceNotFound(NotFound):
class InvalidInstanceIDMalformed(Invalid):
- message = _("Invalid id: %(val) (expecting \"i-...\").")
+ message = _("Invalid id: %(val) (expecting \"i-...\").")