From eb03d47fecd3bfc24243da29ee01679b334a08fe Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 23 Sep 2011 09:22:32 -0700 Subject: Remove AoE, Clean up volume code * Removes Ata Over Ethernet * Adds drivers to libvirt for volumes * Adds initialize_connection and terminate_connection to volume api * Passes connection info back through volume api Change-Id: I1b1626f40bebe8466ab410fb174683293c7c474f --- nova/db/api.py | 36 +------------ nova/db/sqlalchemy/api.py | 60 ++-------------------- .../versions/052_kill_export_devices.py | 51 ++++++++++++++++++ ..._add_connection_info_to_block_device_mapping.py | 35 +++++++++++++ nova/db/sqlalchemy/models.py | 16 +----- 5 files changed, 93 insertions(+), 105 deletions(-) create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py create mode 100644 nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index e0aa5541c..0e00be3f6 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -56,18 +56,13 @@ IMPL = utils.LazyPluggable(FLAGS['db_backend'], sqlalchemy='nova.db.sqlalchemy.api') -class NoMoreBlades(exception.Error): - """No more available blades.""" - pass - - class NoMoreNetworks(exception.Error): """No more available networks.""" pass class NoMoreTargets(exception.Error): - """No more available blades""" + """No more available targets""" pass @@ -814,25 +809,6 @@ def queue_get_for(context, topic, physical_node_id): ################### -def export_device_count(context): - """Return count of export devices.""" - return IMPL.export_device_count(context) - - -def export_device_create_safe(context, values): - """Create an export_device from the values dictionary. - - The device is not returned. If the create violates the unique - constraints because the shelf_id and blade_id already exist, - no exception is raised. - - """ - return IMPL.export_device_create_safe(context, values) - - -################### - - def iscsi_target_count_by_host(context, host): """Return count of export devices.""" return IMPL.iscsi_target_count_by_host(context, host) @@ -908,11 +884,6 @@ def quota_destroy_all_by_project(context, project_id): ################### -def volume_allocate_shelf_and_blade(context, volume_id): - """Atomically allocate a free shelf and blade from the pool.""" - return IMPL.volume_allocate_shelf_and_blade(context, volume_id) - - def volume_allocate_iscsi_target(context, volume_id, host): """Atomically allocate a free iscsi_target from the pool.""" return IMPL.volume_allocate_iscsi_target(context, volume_id, host) @@ -978,11 +949,6 @@ def volume_get_instance(context, volume_id): return IMPL.volume_get_instance(context, volume_id) -def volume_get_shelf_and_blade(context, volume_id): - """Get the shelf and blade allocated to the volume.""" - return IMPL.volume_get_shelf_and_blade(context, volume_id) - - def volume_get_iscsi_target_num(context, volume_id): """Get the target num (tid) allocated to the volume.""" return IMPL.volume_get_iscsi_target_num(context, volume_id) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index aac288767..4b79cbe51 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1164,6 +1164,11 @@ def instance_destroy(context, instance_id): update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) + session.query(models.BlockDeviceMapping).\ + filter_by(instance_id=instance_id).\ + update({'deleted': True, + 'deleted_at': utils.utcnow(), + 'updated_at': literal_column('updated_at')}) @require_context @@ -2002,28 +2007,6 @@ def queue_get_for(_context, topic, physical_node_id): ################### -@require_admin_context -def export_device_count(context): - session = get_session() - return session.query(models.ExportDevice).\ - filter_by(deleted=can_read_deleted(context)).\ - count() - - -@require_admin_context -def export_device_create_safe(context, values): - export_device_ref = models.ExportDevice() - export_device_ref.update(values) - try: - export_device_ref.save() - return export_device_ref - except IntegrityError: - return None - - -################### - - @require_admin_context def iscsi_target_count_by_host(context, host): session = get_session() @@ -2159,24 +2142,6 @@ def quota_destroy_all_by_project(context, project_id): ################### -@require_admin_context -def volume_allocate_shelf_and_blade(context, volume_id): - session = get_session() - with session.begin(): - export_device = session.query(models.ExportDevice).\ - filter_by(volume=None).\ - filter_by(deleted=False).\ - with_lockmode('update').\ - first() - # NOTE(vish): if with_lockmode isn't supported, as in sqlite, - # then this has concurrency issues - if not export_device: - raise db.NoMoreBlades() - export_device.volume_id = volume_id - session.add(export_device) - return (export_device.shelf_id, export_device.blade_id) - - @require_admin_context def volume_allocate_iscsi_target(context, volume_id, host): session = get_session() @@ -2243,9 +2208,6 @@ def volume_destroy(context, volume_id): update({'deleted': True, 'deleted_at': utils.utcnow(), 'updated_at': literal_column('updated_at')}) - session.query(models.ExportDevice).\ - filter_by(volume_id=volume_id).\ - update({'volume_id': None}) session.query(models.IscsiTarget).\ filter_by(volume_id=volume_id).\ update({'volume_id': None}) @@ -2364,18 +2326,6 @@ def volume_get_instance(context, volume_id): return result.instance -@require_admin_context -def volume_get_shelf_and_blade(context, volume_id): - session = get_session() - result = session.query(models.ExportDevice).\ - filter_by(volume_id=volume_id).\ - first() - if not result: - raise exception.ExportDeviceNotFoundForVolume(volume_id=volume_id) - - return (result.shelf_id, result.blade_id) - - @require_admin_context def volume_get_iscsi_target_num(context, volume_id): session = get_session() diff --git a/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py b/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py new file mode 100644 index 000000000..3d4b27fce --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py @@ -0,0 +1,51 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 University of Southern California +# +# 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 Boolean, Column, DateTime, ForeignKey, Integer +from sqlalchemy import MetaData, String, Table +from nova import log as logging + +meta = MetaData() + +# Table definition +export_devices = Table('export_devices', meta, + Column('created_at', DateTime(timezone=False)), + Column('updated_at', DateTime(timezone=False)), + Column('deleted_at', DateTime(timezone=False)), + Column('deleted', Boolean(create_constraint=True, name=None)), + Column('id', Integer(), primary_key=True, nullable=False), + Column('shelf_id', Integer()), + Column('blade_id', Integer()), + Column('volume_id', + Integer(), + ForeignKey('volumes.id'), + nullable=True), + ) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + try: + export_devices.create() + except Exception: + logging.info(repr(export_devices)) + logging.exception('Exception while creating table') + raise + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + export_devices.drop() diff --git a/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py b/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py new file mode 100644 index 000000000..55ef30f4b --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py @@ -0,0 +1,35 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack LLC. +# All Rights Reserved. +# +# 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 * + +from sqlalchemy import Column, MetaData, Table, Text + + +meta = MetaData() + +new_column = Column('connection_info', Text()) + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + table = Table('block_device_mapping', meta, autoload=True) + table.create_column(new_column) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + table = Table('block_device_mapping', meta, autoload=True) + table.c.connection_info.drop() diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 2d9340777..7a4321544 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -470,21 +470,7 @@ class BlockDeviceMapping(BASE, NovaBase): # for no device to suppress devices. no_device = Column(Boolean, nullable=True) - -class ExportDevice(BASE, NovaBase): - """Represates a shelf and blade that a volume can be exported on.""" - __tablename__ = 'export_devices' - __table_args__ = (schema.UniqueConstraint("shelf_id", "blade_id"), - {'mysql_engine': 'InnoDB'}) - id = Column(Integer, primary_key=True) - shelf_id = Column(Integer) - blade_id = Column(Integer) - volume_id = Column(Integer, ForeignKey('volumes.id'), nullable=True) - volume = relationship(Volume, - backref=backref('export_device', uselist=False), - foreign_keys=volume_id, - primaryjoin='and_(ExportDevice.volume_id==Volume.id,' - 'ExportDevice.deleted==False)') + connection_info = Column(Text, nullable=True) class IscsiTarget(BASE, NovaBase): -- cgit