# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
from sqlalchemy import Integer, MetaData, String, Table
-from cinder.i18n import _LE, _LI
-
-
-LOG = logging.getLogger(__name__)
-
def define_tables(meta):
migrations = Table(
tables = define_tables(meta)
for table in tables:
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception(_LE('Exception while creating table.'))
- raise
+ table.create()
if migrate_engine.name == "mysql":
tables = ["sm_flavors",
tables = define_tables(meta)
tables.reverse()
for table in tables:
- LOG.info(_LI("dropping table %(table)s"), {'table': table})
table.drop()
# under the License.
from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_charset='utf8',
)
- try:
- quota_classes.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(quota_classes))
- raise
+ quota_classes.create()
quota_usages = Table('quota_usages', meta,
Column('created_at', DateTime(timezone=False)),
mysql_charset='utf8',
)
- try:
- quota_usages.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(quota_usages))
- raise
+ quota_usages.create()
reservations = Table('reservations', meta,
Column('created_at', DateTime(timezone=False)),
mysql_charset='utf8',
)
- try:
- reservations.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(reservations))
- raise
+ reservations.create()
def downgrade(migrate_engine):
'name': fk_name}
if fk_name:
- try:
- fkey = ForeignKeyConstraint(**params)
- fkey.drop()
- except Exception:
- LOG.error(_LE("Dropping foreign key %s failed."), fk_name)
+ fkey = ForeignKeyConstraint(**params)
+ fkey.drop()
quota_classes = Table('quota_classes', meta, autoload=True)
- try:
- quota_classes.drop()
- except Exception:
- LOG.error(_LE("quota_classes table not dropped"))
- raise
+ quota_classes.drop()
quota_usages = Table('quota_usages', meta, autoload=True)
- try:
- quota_usages.drop()
- except Exception:
- LOG.error(_LE("quota_usages table not dropped"))
- raise
+ quota_usages.drop()
reservations = Table('reservations', meta, autoload=True)
- try:
- reservations.drop()
- except Exception:
- LOG.error(_LE("reservations table not dropped"))
- raise
+ reservations.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column, DateTime, Text, Boolean
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
try:
volume_glance_metadata.create()
except Exception:
- LOG.exception(_LE("Exception while creating table "
- "'volume_glance_metadata'"))
meta.drop_all(tables=[volume_glance_metadata])
raise
volume_glance_metadata = Table('volume_glance_metadata',
meta, autoload=True)
- try:
- volume_glance_metadata.drop()
- except Exception:
- LOG.error(_LE("volume_glance_metadata table not dropped"))
- raise
+ volume_glance_metadata.drop()
import uuid
from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
from sqlalchemy import Integer, MetaData, String, Table
-from cinder.i18n import _LI
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Convert volume_type_id to UUID."""
name=fkey_name)
try:
fkey.create()
- LOG.info(_LI('Created foreign key %s'), fkey_name)
except Exception:
if migrate_engine.url.get_dialect().name.startswith('sqlite'):
pass
name=fkey_name)
try:
fkey.create()
- LOG.info(_LI('Created foreign key %s'), fkey_name)
except Exception:
if migrate_engine.url.get_dialect().name.startswith('sqlite'):
pass
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column
from sqlalchemy import MetaData, String, Table
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Add source volume id column to volumes."""
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, Integer, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_engine='InnoDB'
)
- try:
- backups.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(backups))
- raise
+ backups.create()
def downgrade(migrate_engine):
meta.bind = migrate_engine
backups = Table('backups', meta, autoload=True)
- try:
- backups.drop()
- except Exception:
- LOG.error(_LE("backups table not dropped"))
- raise
+ backups.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_engine='InnoDB'
)
- try:
- snapshot_metadata.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(snapshot_metadata))
- raise
+ snapshot_metadata.create()
def downgrade(migrate_engine):
snapshot_metadata = Table('snapshot_metadata',
meta,
autoload=True)
- try:
- snapshot_metadata.drop()
- except Exception:
- LOG.error(_LE("snapshot_metadata table not dropped"))
- raise
+ snapshot_metadata.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import MetaData, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_charset='utf8'
)
- try:
- transfers.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(transfers))
- raise
+ transfers.create()
def downgrade(migrate_engine):
transfers = Table('transfers',
meta,
autoload=True)
- try:
- transfers.drop()
- except Exception:
- LOG.error(_LE("transfers table not dropped"))
- raise
+ transfers.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime, Integer
from sqlalchemy import MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
TABLE_NAME = 'migrations'
meta = MetaData()
meta.bind = migrate_engine
table = Table(TABLE_NAME, meta, autoload=True)
- try:
- table.drop()
- except Exception:
- LOG.error(_LE("migrations table not dropped"))
- raise
+ table.drop()
def downgrade(migrate_engine):
mysql_charset='utf8'
)
- try:
- table.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created"), repr(table))
- raise
+ table.create()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
from sqlalchemy import Integer, MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
tables = [sm_volume, sm_backend_config, sm_flavors]
for table in tables:
- try:
- table.drop()
- except Exception:
- LOG.exception(_LE('Exception while dropping table %s.'),
- repr(table))
- raise
+ table.drop()
def downgrade(migrate_engine):
tables = [sm_flavors, sm_backend_config, sm_volume]
for table in tables:
- try:
- table.create()
- except Exception:
- LOG.exception(_LE('Exception while creating table %s.'),
- repr(table))
- raise
+ table.create()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column, ForeignKey, MetaData, Table
from sqlalchemy import Boolean, DateTime, Integer, String
-from cinder.i18n import _LE
-
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
# encryption key UUID -- must be stored per volume
volumes = Table('volumes', meta, autoload=True)
encryption_key = Column('encryption_key_id', String(36))
- try:
- volumes.create_column(encryption_key)
- except Exception:
- LOG.error(_LE("Column |%s| not created!"), repr(encryption_key))
- raise
+ volumes.create_column(encryption_key)
# encryption key UUID and volume type id -- must be stored per snapshot
snapshots = Table('snapshots', meta, autoload=True)
encryption_key = Column('encryption_key_id', String(36))
- try:
- snapshots.create_column(encryption_key)
- except Exception:
- LOG.error(_LE("Column |%s| not created!"), repr(encryption_key))
- raise
+ snapshots.create_column(encryption_key)
volume_type = Column('volume_type_id', String(36))
- try:
- snapshots.create_column(volume_type)
- except Exception:
- LOG.error(_LE("Column |%s| not created!"), repr(volume_type))
- raise
+ snapshots.create_column(volume_type)
volume_types = Table('volume_types', meta, autoload=True)
mysql_charset='utf8'
)
- try:
- encryption.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(encryption))
- raise
+ encryption.create()
def downgrade(migrate_engine):
# drop encryption key UUID for volumes
volumes = Table('volumes', meta, autoload=True)
- try:
- volumes.c.encryption_key_id.drop()
- except Exception:
- LOG.error(_LE("encryption_key_id column not dropped from volumes"))
- raise
+ volumes.c.encryption_key_id.drop()
# drop encryption key UUID and volume type id for snapshots
snapshots = Table('snapshots', meta, autoload=True)
- try:
- snapshots.c.encryption_key_id.drop()
- except Exception:
- LOG.error(_LE("encryption_key_id column not dropped from snapshots"))
- raise
- try:
- snapshots.c.volume_type_id.drop()
- except Exception:
- LOG.error(_LE("volume_type_id column not dropped from snapshots"))
- raise
+ snapshots.c.encryption_key_id.drop()
+ snapshots.c.volume_type_id.drop()
# drop encryption types table
encryption = Table('encryption', meta, autoload=True)
- try:
- encryption.drop()
- except Exception:
- LOG.error(_LE("encryption table not dropped"))
- raise
+ encryption.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import ForeignKey, MetaData, String, Table
from migrate import ForeignKeyConstraint
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Add volume_type_rate_limit table."""
mysql_charset='utf8'
)
- try:
- quality_of_service_specs.create()
- except Exception:
- LOG.error(_LE("Table quality_of_service_specs not created!"))
- raise
+ quality_of_service_specs.create()
volume_types = Table('volume_types', meta, autoload=True)
qos_specs_id = Column('qos_specs_id', String(36),
ForeignKey('quality_of_service_specs.id'))
- try:
- volume_types.create_column(qos_specs_id)
- volume_types.update().values(qos_specs_id=None).execute()
- except Exception:
- LOG.error(_LE("Added qos_specs_id column to volume type table "
- "failed."))
- raise
+ volume_types.create_column(qos_specs_id)
+ volume_types.update().values(qos_specs_id=None).execute()
def downgrade(migrate_engine):
'refcolumns': [ref_table.c['id']],
'name': 'volume_types_ibfk_1'}
- try:
- fkey = ForeignKeyConstraint(**params)
- fkey.drop()
- except Exception:
- LOG.error(_LE("Dropping foreign key volume_types_ibfk_1 failed"))
+ fkey = ForeignKeyConstraint(**params)
+ fkey.drop()
volume_types = Table('volume_types', meta, autoload=True)
qos_specs_id = Column('qos_specs_id', String(36))
- try:
- volume_types.drop_column(qos_specs_id)
- except Exception:
- LOG.error(_LE("Dropping qos_specs_id column failed."))
- raise
-
- try:
- qos_specs.drop()
-
- except Exception:
- LOG.error(_LE("Dropping quality_of_service_specs table failed."))
- raise
+ volume_types.drop_column(qos_specs_id)
+ qos_specs.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_charset='utf8'
)
- try:
- volume_admin_metadata.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(volume_admin_metadata))
- raise
+ volume_admin_metadata.create()
def downgrade(migrate_engine):
volume_admin_metadata = Table('volume_admin_metadata',
meta,
autoload=True)
- try:
- volume_admin_metadata.drop()
- except Exception:
- LOG.error(_LE("volume_admin_metadata table not dropped"))
- raise
+ volume_admin_metadata.drop()
import datetime
from oslo_config import cfg
-from oslo_log import log as logging
from sqlalchemy import MetaData, Table
-from cinder.i18n import _LE, _LI
-
# Get default values via config. The defaults will either
# come from the default values set in the quota option
# configuration or via cinder.conf if the user has configured
CONF.import_opt('quota_volumes', 'cinder.quota')
CONF.import_opt('quota_snapshots', 'cinder.quota')
CONF.import_opt('quota_gigabytes', 'cinder.quota')
-LOG = logging.getLogger(__name__)
CLASS_NAME = 'default'
CREATED_AT = datetime.datetime.now() # noqa
# Do not add entries if there are already 'default' entries. We don't
# want to write over something the user added.
if rows:
- LOG.info(_LI("Found existing 'default' entries in the quota_classes "
- "table. Skipping insertion of default values."))
return
- try:
- # Set default volumes
- qci = quota_classes.insert()
- qci.execute({'created_at': CREATED_AT,
- 'class_name': CLASS_NAME,
- 'resource': 'volumes',
- 'hard_limit': CONF.quota_volumes,
- 'deleted': False, })
- # Set default snapshots
- qci.execute({'created_at': CREATED_AT,
- 'class_name': CLASS_NAME,
- 'resource': 'snapshots',
- 'hard_limit': CONF.quota_snapshots,
- 'deleted': False, })
- # Set default gigabytes
- qci.execute({'created_at': CREATED_AT,
- 'class_name': CLASS_NAME,
- 'resource': 'gigabytes',
- 'hard_limit': CONF.quota_gigabytes,
- 'deleted': False, })
- LOG.info(_LI("Added default quota class data into the DB."))
- except Exception:
- LOG.error(_LE("Default quota class data not inserted into the DB."))
- raise
+ # Set default volumes
+ qci = quota_classes.insert()
+ qci.execute({'created_at': CREATED_AT,
+ 'class_name': CLASS_NAME,
+ 'resource': 'volumes',
+ 'hard_limit': CONF.quota_volumes,
+ 'deleted': False, })
+ # Set default snapshots
+ qci.execute({'created_at': CREATED_AT,
+ 'class_name': CLASS_NAME,
+ 'resource': 'snapshots',
+ 'hard_limit': CONF.quota_snapshots,
+ 'deleted': False, })
+ # Set default gigabytes
+ qci.execute({'created_at': CREATED_AT,
+ 'class_name': CLASS_NAME,
+ 'resource': 'gigabytes',
+ 'hard_limit': CONF.quota_gigabytes,
+ 'deleted': False, })
def downgrade(migrate_engine):
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Index, MetaData, Table
-from cinder.i18n import _LI
-
-LOG = logging.getLogger(__name__)
-
def _get_deleted_expire_index(table):
members = sorted(['deleted', 'expire'])
reservations = Table('reservations', meta, autoload=True)
if _get_deleted_expire_index(reservations):
- LOG.info(_LI('Skipped adding reservations_deleted_expire_idx '
- 'because an equivalent index already exists.'))
return
# Based on expire_reservations query
index = _get_deleted_expire_index(reservations)
if index:
index.drop(migrate_engine)
- else:
- LOG.info(_LI('Skipped removing reservations_deleted_expire_idx '
- 'because index does not exist.'))
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column
from sqlalchemy import MetaData, String, Table
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Add replication columns to volumes."""
# under the License.
from migrate import ForeignKeyConstraint
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import ForeignKey, MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_charset='utf8',
)
- try:
- consistencygroups.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(consistencygroups))
- raise
+ consistencygroups.create()
# New table
cgsnapshots = Table(
mysql_charset='utf8',
)
- try:
- cgsnapshots.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(cgsnapshots))
- raise
+ cgsnapshots.create()
# Add column to volumes table
volumes = Table('volumes', meta, autoload=True)
consistencygroup_id = Column('consistencygroup_id', String(36),
ForeignKey('consistencygroups.id'))
- try:
- volumes.create_column(consistencygroup_id)
- volumes.update().values(consistencygroup_id=None).execute()
- except Exception:
- LOG.error(_LE("Adding consistencygroup_id column to volumes table"
- " failed."))
- raise
+ volumes.create_column(consistencygroup_id)
+ volumes.update().values(consistencygroup_id=None).execute()
# Add column to snapshots table
snapshots = Table('snapshots', meta, autoload=True)
cgsnapshot_id = Column('cgsnapshot_id', String(36),
ForeignKey('cgsnapshots.id'))
- try:
- snapshots.create_column(cgsnapshot_id)
- snapshots.update().values(cgsnapshot_id=None).execute()
- except Exception:
- LOG.error(_LE("Adding cgsnapshot_id column to snapshots table"
- " failed."))
- raise
+ snapshots.create_column(cgsnapshot_id)
+ snapshots.update().values(cgsnapshot_id=None).execute()
def downgrade(migrate_engine):
'refcolumns': [ref_table.c['id']],
'name': 'snapshots_ibfk_1'}
- try:
- fkey = ForeignKeyConstraint(**params)
- fkey.drop()
- except Exception:
- LOG.error(_LE("Dropping foreign key 'cgsnapshot_id' in "
- "the 'snapshots' table failed."))
+ fkey = ForeignKeyConstraint(**params)
+ fkey.drop()
snapshots = Table('snapshots', meta, autoload=True)
cgsnapshot_id = snapshots.columns.cgsnapshot_id
'refcolumns': [ref_table.c['id']],
'name': 'volumes_ibfk_1'}
- try:
- fkey = ForeignKeyConstraint(**params)
- fkey.drop()
- except Exception:
- LOG.error(_LE("Dropping foreign key 'consistencygroup_id' in "
- "the 'volumes' table failed."))
+ fkey = ForeignKeyConstraint(**params)
+ fkey.drop()
volumes = Table('volumes', meta, autoload=True)
consistencygroup_id = volumes.columns.consistencygroup_id
# Drop table
cgsnapshots = Table('cgsnapshots', meta, autoload=True)
- try:
- cgsnapshots.drop()
- except Exception:
- LOG.error(_LE("cgsnapshots table not dropped"))
- raise
+ cgsnapshots.drop()
# Drop table
consistencygroups = Table('consistencygroups', meta, autoload=True)
- try:
- consistencygroups.drop()
- except Exception:
- LOG.error(_LE("consistencygroups table not dropped"))
- raise
+ consistencygroups.drop()
import datetime
from oslo_config import cfg
-from oslo_log import log as logging
from sqlalchemy import MetaData, Table
-from cinder.i18n import _LE, _LI
-
# Get default values via config. The defaults will either
# come from the default values set in the quota option
# configuration or via cinder.conf if the user has configured
# default values for quotas there.
CONF = cfg.CONF
CONF.import_opt('quota_consistencygroups', 'cinder.quota')
-LOG = logging.getLogger(__name__)
CLASS_NAME = 'default'
CREATED_AT = datetime.datetime.now() # noqa
# Do not add entries if there are already 'consistencygroups' entries.
if rows:
- LOG.info(_LI("Found existing 'consistencygroups' entries in the "
- "quota_classes table. Skipping insertion."))
return
- try:
- # Set consistencygroups
- qci = quota_classes.insert()
- qci.execute({'created_at': CREATED_AT,
- 'class_name': CLASS_NAME,
- 'resource': 'consistencygroups',
- 'hard_limit': CONF.quota_consistencygroups,
- 'deleted': False, })
- LOG.info(_LI("Added default consistencygroups quota class data into "
- "the DB."))
- except Exception:
- LOG.error(_LE("Default consistencygroups quota class data not "
- "inserted into the DB."))
- raise
+ # Set consistencygroups
+ qci = quota_classes.insert()
+ qci.execute({'created_at': CREATED_AT,
+ 'class_name': CLASS_NAME,
+ 'resource': 'consistencygroups',
+ 'hard_limit': CONF.quota_consistencygroups,
+ 'deleted': False, })
def downgrade(migrate_engine):
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Boolean, Column, DateTime, UniqueConstraint
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
volume_types = Table('volume_types', meta, autoload=True)
is_public = Column('is_public', Boolean)
- try:
- volume_types.create_column(is_public)
- # pylint: disable=E1120
- volume_types.update().values(is_public=True).execute()
- except Exception:
- LOG.error(_LE("Column |%s| not created!"), repr(is_public))
- raise
+ volume_types.create_column(is_public)
+ # pylint: disable=E1120
+ volume_types.update().values(is_public=True).execute()
volume_type_projects = Table(
'volume_type_projects', meta,
mysql_engine='InnoDB',
)
- try:
- volume_type_projects.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(volume_type_projects))
- raise
+ volume_type_projects.create()
def downgrade(migrate_engine):
volume_types = Table('volume_types', meta, autoload=True)
is_public = volume_types.columns.is_public
- try:
- volume_types.drop_column(is_public)
- except Exception:
- LOG.error(_LE("volume_types.is_public column not dropped"))
- raise
+ volume_types.drop_column(is_public)
volume_type_projects = Table('volume_type_projects', meta, autoload=True)
- try:
- volume_type_projects.drop()
- except Exception:
- LOG.error(_LE("volume_type_projects table not dropped"))
- raise
+ volume_type_projects.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column
from sqlalchemy import MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Add cgsnapshot_id column to consistencygroups."""
consistencygroups = Table('consistencygroups', meta, autoload=True)
cgsnapshot_id = Column('cgsnapshot_id', String(36))
- try:
- consistencygroups.create_column(cgsnapshot_id)
- consistencygroups.update().values(cgsnapshot_id=None).execute()
- except Exception:
- LOG.error(_LE("Adding cgsnapshot_id column to consistencygroups "
- "table failed."))
- raise
+ consistencygroups.create_column(cgsnapshot_id)
+ consistencygroups.update().values(cgsnapshot_id=None).execute()
def downgrade(migrate_engine):
consistencygroups = Table('consistencygroups', meta, autoload=True)
cgsnapshot_id = consistencygroups.columns.cgsnapshot_id
- try:
- consistencygroups.drop_column(cgsnapshot_id)
- except Exception:
- LOG.error(_LE("Dropping cgsnapshot_id column from consistencygroups "
- "table failed."))
- raise
+ consistencygroups.drop_column(cgsnapshot_id)
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column, DateTime, Integer
from sqlalchemy import MetaData, String, Table, UniqueConstraint
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
mysql_charset='utf8'
)
- try:
- initiator_data.create()
- except Exception:
- LOG.error(_LE("Table |%s| not created!"), repr(initiator_data))
- raise
+ initiator_data.create()
def downgrade(migrate_engine):
meta.bind = migrate_engine
table_name = 'driver_initiator_data'
initiator_data = Table(table_name, meta, autoload=True)
- try:
- initiator_data.drop()
- except Exception:
- LOG.error(_LE("%(table_name)s table not dropped"),
- {'table_name': table_name})
- raise
+ initiator_data.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column, MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
backups = Table('backups', meta, autoload=True)
parent_id = Column('parent_id', String(length=36))
- try:
- backups.create_column(parent_id)
- backups.update().values(parent_id=None).execute()
- except Exception:
- LOG.error(_LE("Adding parent_id column to backups table failed."))
- raise
+ backups.create_column(parent_id)
+ backups.update().values(parent_id=None).execute()
def downgrade(migrate_engine):
backups = Table('backups', meta, autoload=True)
parent_id = backups.columns.parent_id
- try:
- backups.drop_column(parent_id)
- except Exception:
- LOG.error(_LE("Dropping parent_id column from backups table failed."))
- raise
+ backups.drop_column(parent_id)
import datetime
import uuid
-from oslo_log import log as logging
import six
from sqlalchemy import Boolean, Column, DateTime
from sqlalchemy import ForeignKey, MetaData, String, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
CREATED_AT = datetime.datetime.now() # noqa
mysql_engine='InnoDB'
)
- try:
- volume_attachment.create()
- except Exception:
- LOG.error(_LE("Table volume_attachment not created!"))
- raise
+ volume_attachment.create()
# now migrate existing volume attachment info into the
# new volume_attachment table
attach_time=attachment.attach_time,
instance_uuid=attachment.instance_uuid).\
execute()
- try:
- volume_attachment.drop()
-
- except Exception:
- LOG.error(_LE("Dropping volume_attachment table failed."))
- raise
+ volume_attachment.drop()
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from sqlalchemy import Column, MetaData, DateTime, Table
-from cinder.i18n import _LE
-
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
services = Table('services', meta, autoload=True)
modified_at = Column('modified_at', DateTime(timezone=False))
- try:
- services.create_column(modified_at)
- except Exception:
- LOG.error(_LE("Adding modified_at column to services table failed."))
- raise
+ services.create_column(modified_at)
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
services = Table('services', meta, autoload=True)
- try:
- services.drop_column('modified_at')
- except Exception:
- LOG.error(_LE("Unable to drop modified_at column from services"
- "table."))
- raise
+ services.drop_column('modified_at')
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_log import log as logging
from oslo_utils import timeutils
from sqlalchemy import MetaData, Table
-from cinder.i18n import _LE
# Get default value via config. The default will either
# come from the default value set in the quota configuration option
# or via cinder.conf if the user has configured
# default value for per volume size limit there.
-LOG = logging.getLogger(__name__)
-
def upgrade(migrate_engine):
"""Add default "per_volume_gigabytes" row into DB."""
if row:
return
- try:
- # Set default per_volume_gigabytes for per volume size
- qci = quota_classes.insert()
- qci.execute({'created_at': timeutils.utcnow(),
- 'class_name': 'default',
- 'resource': 'per_volume_gigabytes',
- 'hard_limit': -1,
- 'deleted': False, })
- except Exception:
- LOG.error(_LE("Default per_volume_gigabytes row not inserted "
- "into the quota_classes."))
- raise
+ # Set default per_volume_gigabytes for per volume size
+ qci = quota_classes.insert()
+ qci.execute({'created_at': timeutils.utcnow(),
+ 'class_name': 'default',
+ 'resource': 'per_volume_gigabytes',
+ 'hard_limit': -1,
+ 'deleted': False, })
def downgrade(migrate_engine):