diff --git a/nova/db/api.py b/nova/db/api.py index cba0e7456ee..bf94747df08 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 6496ab7b997..ba3c12b41e8 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 00000000000..79e99503af0 --- /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 7f70a5d5567..b15cece8d20 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -278,8 +278,8 @@ def name(self): # 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 e1caf28fe9d..4de0f65d1b7 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-...\").")