Merge "Compact Kilo database migrations"
This commit is contained in:
commit
67f3f6d51b
@ -28,7 +28,7 @@ from cinder import exception
|
||||
from cinder.i18n import _
|
||||
|
||||
|
||||
INIT_VERSION = 000
|
||||
INIT_VERSION = 45
|
||||
|
||||
_IMPL = None
|
||||
_LOCK = threading.Lock()
|
||||
|
@ -1,258 +0,0 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
#
|
||||
# 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
|
||||
from sqlalchemy import Integer, MetaData, String, Table
|
||||
|
||||
|
||||
def define_tables(meta):
|
||||
migrations = Table(
|
||||
'migrations', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('source_compute', String(length=255)),
|
||||
Column('dest_compute', String(length=255)),
|
||||
Column('dest_host', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
Column('instance_uuid', String(length=255)),
|
||||
Column('old_instance_type_id', Integer),
|
||||
Column('new_instance_type_id', Integer),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
services = Table(
|
||||
'services', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('host', String(length=255)),
|
||||
Column('binary', String(length=255)),
|
||||
Column('topic', String(length=255)),
|
||||
Column('report_count', Integer, nullable=False),
|
||||
Column('disabled', Boolean),
|
||||
Column('availability_zone', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
sm_flavors = Table(
|
||||
'sm_flavors', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('label', String(length=255)),
|
||||
Column('description', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
sm_backend_config = Table(
|
||||
'sm_backend_config', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('flavor_id', Integer, ForeignKey('sm_flavors.id'),
|
||||
nullable=False),
|
||||
Column('sr_uuid', String(length=255)),
|
||||
Column('sr_type', String(length=255)),
|
||||
Column('config_params', String(length=2047)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
sm_volume = Table(
|
||||
'sm_volume', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(length=36),
|
||||
ForeignKey('volumes.id'),
|
||||
primary_key=True,
|
||||
nullable=False),
|
||||
Column('backend_id', Integer, ForeignKey('sm_backend_config.id'),
|
||||
nullable=False),
|
||||
Column('vdi_uuid', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
snapshots = Table(
|
||||
'snapshots', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(length=36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(length=36), nullable=False),
|
||||
Column('user_id', String(length=255)),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
Column('progress', String(length=255)),
|
||||
Column('volume_size', Integer),
|
||||
Column('scheduled_at', DateTime),
|
||||
Column('display_name', String(length=255)),
|
||||
Column('display_description', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_types = Table(
|
||||
'volume_types', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('name', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_metadata = Table(
|
||||
'volume_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_id', String(length=36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('key', String(length=255)),
|
||||
Column('value', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_type_extra_specs = Table(
|
||||
'volume_type_extra_specs', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_type_id', Integer, ForeignKey('volume_types.id'),
|
||||
nullable=False),
|
||||
Column('key', String(length=255)),
|
||||
Column('value', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volumes = Table(
|
||||
'volumes', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(length=36), primary_key=True, nullable=False),
|
||||
Column('ec2_id', String(length=255)),
|
||||
Column('user_id', String(length=255)),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('host', String(length=255)),
|
||||
Column('size', Integer),
|
||||
Column('availability_zone', String(length=255)),
|
||||
Column('instance_uuid', String(length=36)),
|
||||
Column('mountpoint', String(length=255)),
|
||||
Column('attach_time', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
Column('attach_status', String(length=255)),
|
||||
Column('scheduled_at', DateTime),
|
||||
Column('launched_at', DateTime),
|
||||
Column('terminated_at', DateTime),
|
||||
Column('display_name', String(length=255)),
|
||||
Column('display_description', String(length=255)),
|
||||
Column('provider_location', String(length=256)),
|
||||
Column('provider_auth', String(length=256)),
|
||||
Column('snapshot_id', String(length=36)),
|
||||
Column('volume_type_id', Integer),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
quotas = Table(
|
||||
'quotas', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('resource', String(length=255), nullable=False),
|
||||
Column('hard_limit', Integer),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
iscsi_targets = Table(
|
||||
'iscsi_targets', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('target_num', Integer),
|
||||
Column('host', String(length=255)),
|
||||
Column('volume_id', String(length=36), ForeignKey('volumes.id'),
|
||||
nullable=True),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
return [sm_flavors,
|
||||
sm_backend_config,
|
||||
snapshots,
|
||||
volume_types,
|
||||
volumes,
|
||||
iscsi_targets,
|
||||
migrations,
|
||||
quotas,
|
||||
services,
|
||||
sm_volume,
|
||||
volume_metadata,
|
||||
volume_type_extra_specs]
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# create all tables
|
||||
# Take care on create order for those with FK dependencies
|
||||
tables = define_tables(meta)
|
||||
|
||||
for table in tables:
|
||||
table.create()
|
||||
|
||||
if migrate_engine.name == "mysql":
|
||||
tables = ["sm_flavors",
|
||||
"sm_backend_config",
|
||||
"snapshots",
|
||||
"volume_types",
|
||||
"volumes",
|
||||
"iscsi_targets",
|
||||
"migrate_version",
|
||||
"migrations",
|
||||
"quotas",
|
||||
"services",
|
||||
"sm_volume",
|
||||
"volume_metadata",
|
||||
"volume_type_extra_specs"]
|
||||
|
||||
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||
for table in tables:
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE %s CONVERT TO CHARACTER SET utf8" % table)
|
||||
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||
migrate_engine.execute(
|
||||
"ALTER DATABASE %s DEFAULT CHARACTER SET utf8" %
|
||||
migrate_engine.url.database)
|
||||
migrate_engine.execute("ALTER TABLE %s Engine=InnoDB" % table)
|
@ -1,89 +0,0 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
#
|
||||
# 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
|
||||
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# New table
|
||||
quota_classes = Table('quota_classes', 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),
|
||||
Column('class_name',
|
||||
String(length=255),
|
||||
index=True),
|
||||
Column('resource',
|
||||
String(length=255)),
|
||||
Column('hard_limit', Integer(), nullable=True),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
quota_classes.create()
|
||||
|
||||
quota_usages = Table('quota_usages', 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),
|
||||
Column('project_id',
|
||||
String(length=255),
|
||||
index=True),
|
||||
Column('resource',
|
||||
String(length=255)),
|
||||
Column('in_use', Integer(), nullable=False),
|
||||
Column('reserved', Integer(), nullable=False),
|
||||
Column('until_refresh', Integer(), nullable=True),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
quota_usages.create()
|
||||
|
||||
reservations = Table('reservations', 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),
|
||||
Column('uuid',
|
||||
String(length=36),
|
||||
nullable=False),
|
||||
Column('usage_id',
|
||||
Integer(),
|
||||
ForeignKey('quota_usages.id'),
|
||||
nullable=False),
|
||||
Column('project_id',
|
||||
String(length=255),
|
||||
index=True),
|
||||
Column('resource',
|
||||
String(length=255)),
|
||||
Column('delta', Integer(), nullable=False),
|
||||
Column('expire', DateTime(timezone=False)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
reservations.create()
|
@ -1,55 +0,0 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
#
|
||||
# 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 Column, DateTime, Text, Boolean
|
||||
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# Just for the ForeignKey and column creation to succeed, these are not the
|
||||
# actual definitions of tables .
|
||||
#
|
||||
Table('volumes',
|
||||
meta,
|
||||
Column('id', Integer(), primary_key=True, nullable=False),
|
||||
mysql_engine='InnoDB')
|
||||
Table('snapshots',
|
||||
meta,
|
||||
Column('id', Integer(), primary_key=True, nullable=False),
|
||||
mysql_engine='InnoDB')
|
||||
# Create new table
|
||||
volume_glance_metadata = Table(
|
||||
'volume_glance_metadata',
|
||||
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('volume_id', String(length=36), ForeignKey('volumes.id')),
|
||||
Column('snapshot_id', String(length=36),
|
||||
ForeignKey('snapshots.id')),
|
||||
Column('key', String(255)),
|
||||
Column('value', Text),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
try:
|
||||
volume_glance_metadata.create()
|
||||
except Exception:
|
||||
meta.drop_all(tables=[volume_glance_metadata])
|
||||
raise
|
@ -1,81 +0,0 @@
|
||||
# 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.
|
||||
|
||||
import uuid
|
||||
|
||||
from migrate import ForeignKeyConstraint
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Convert volume_type_id to UUID."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
volume_types = Table('volume_types', meta, autoload=True)
|
||||
extra_specs = Table('volume_type_extra_specs', meta, autoload=True)
|
||||
|
||||
fkey_remove_list = [volumes.c.volume_type_id,
|
||||
volume_types.c.id,
|
||||
extra_specs.c.volume_type_id]
|
||||
|
||||
for column in fkey_remove_list:
|
||||
fkeys = list(column.foreign_keys)
|
||||
if fkeys:
|
||||
fkey_name = fkeys[0].constraint.name
|
||||
fkey = ForeignKeyConstraint(columns=[column],
|
||||
refcolumns=[volume_types.c.id],
|
||||
name=fkey_name)
|
||||
|
||||
try:
|
||||
fkey.drop()
|
||||
except Exception:
|
||||
if migrate_engine.url.get_dialect().name.startswith('sqlite'):
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
volumes.c.volume_type_id.alter(String(36))
|
||||
volume_types.c.id.alter(String(36))
|
||||
extra_specs.c.volume_type_id.alter(String(36))
|
||||
|
||||
vtype_list = list(volume_types.select().execute())
|
||||
for t in vtype_list:
|
||||
new_id = str(uuid.uuid4())
|
||||
|
||||
volumes.update().\
|
||||
where(volumes.c.volume_type_id == t['id']).\
|
||||
values(volume_type_id=new_id).execute()
|
||||
|
||||
extra_specs.update().\
|
||||
where(extra_specs.c.volume_type_id == t['id']).\
|
||||
values(volume_type_id=new_id).execute()
|
||||
|
||||
volume_types.update().\
|
||||
where(volume_types.c.id == t['id']).\
|
||||
values(id=new_id).execute()
|
||||
|
||||
for column in fkey_remove_list:
|
||||
fkeys = list(column.foreign_keys)
|
||||
if fkeys:
|
||||
fkey_name = fkeys[0].constraint.name
|
||||
fkey = ForeignKeyConstraint(columns=[column],
|
||||
refcolumns=[volume_types.c.id],
|
||||
name=fkey_name)
|
||||
try:
|
||||
fkey.create()
|
||||
except Exception:
|
||||
if migrate_engine.url.get_dialect().name.startswith('sqlite'):
|
||||
pass
|
||||
else:
|
||||
raise
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add source volume id column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
source_volid = Column('source_volid', String(36))
|
||||
volumes.create_column(source_volid)
|
||||
volumes.update().values(source_volid=None).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
snapshots = Table('snapshots', meta, autoload=True)
|
||||
provider_location = Column('provider_location', String(255))
|
||||
snapshots.create_column(provider_location)
|
||||
snapshots.update().values(provider_location=None).execute()
|
@ -1,27 +0,0 @@
|
||||
# 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
|
||||
from migrate.changeset.constraint import ForeignKeyConstraint
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
snapshots = Table('snapshots', meta, autoload=True)
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
|
||||
ForeignKeyConstraint(
|
||||
columns=[snapshots.c.volume_id],
|
||||
refcolumns=[volumes.c.id]).create()
|
@ -1,49 +0,0 @@
|
||||
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
|
||||
# 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 Boolean, Column, DateTime
|
||||
from sqlalchemy import MetaData, Integer, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# New table
|
||||
backups = Table(
|
||||
'backups', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), nullable=False),
|
||||
Column('user_id', String(length=255)),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('host', String(length=255)),
|
||||
Column('availability_zone', String(length=255)),
|
||||
Column('display_name', String(length=255)),
|
||||
Column('display_description', String(length=255)),
|
||||
Column('container', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
Column('fail_reason', String(length=255)),
|
||||
Column('service_metadata', String(length=255)),
|
||||
Column('service', String(length=255)),
|
||||
Column('size', Integer()),
|
||||
Column('object_count', Integer()),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
backups.create()
|
@ -1,38 +0,0 @@
|
||||
# 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
|
||||
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
Table('snapshots', meta, autoload=True)
|
||||
|
||||
# New table
|
||||
snapshot_metadata = Table(
|
||||
'snapshot_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('snapshot_id', String(length=36), ForeignKey('snapshots.id'),
|
||||
nullable=False),
|
||||
Column('key', String(length=255)),
|
||||
Column('value', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
snapshot_metadata.create()
|
@ -1,41 +0,0 @@
|
||||
# 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
|
||||
from sqlalchemy import MetaData, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
Table('volumes', meta, autoload=True)
|
||||
|
||||
# New table
|
||||
transfers = Table(
|
||||
'transfers', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('deleted_at', DateTime(timezone=False)),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(length=36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('display_name', String(length=255)),
|
||||
Column('salt', String(length=255)),
|
||||
Column('crypt_hash', String(length=255)),
|
||||
Column('expires_at', DateTime(timezone=False)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
transfers.create()
|
@ -1,33 +0,0 @@
|
||||
# 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, MetaData, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add bootable column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
bootable = Column('bootable', Boolean)
|
||||
|
||||
volumes.create_column(bootable)
|
||||
volumes.update().values(bootable=False).execute()
|
||||
|
||||
glance_metadata = Table('volume_glance_metadata', meta, autoload=True)
|
||||
glance_items = list(glance_metadata.select().execute())
|
||||
for item in glance_items:
|
||||
volumes.update().\
|
||||
where(volumes.c.id == item['volume_id']).\
|
||||
values(bootable=True).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add attach host column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
attached_host = Column('attached_host', String(255))
|
||||
volumes.create_column(attached_host)
|
||||
volumes.update().values(attached_host=None).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add provider_geometry column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
provider_geometry = Column('provider_geometry', String(255))
|
||||
volumes.create_column(provider_geometry)
|
||||
volumes.update().values(provider_geometry=None).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 String, Column, MetaData, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add _name_id column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
_name_id = Column('_name_id', String(36))
|
||||
volumes.create_column(_name_id)
|
||||
volumes.update().values(_name_id=None).execute()
|
@ -1,23 +0,0 @@
|
||||
# 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
|
||||
|
||||
|
||||
TABLE_NAME = 'migrations'
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
table = Table(TABLE_NAME, meta, autoload=True)
|
||||
table.drop()
|
@ -1,29 +0,0 @@
|
||||
# Copyright 2013 OpenStack Foundation
|
||||
#
|
||||
# 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
|
||||
|
||||
sm_backend_config = Table('sm_backend_config', meta, autoload=True)
|
||||
sm_flavors = Table('sm_flavors', meta, autoload=True)
|
||||
sm_volume = Table('sm_volume', meta, autoload=True)
|
||||
|
||||
tables = [sm_volume, sm_backend_config, sm_flavors]
|
||||
|
||||
for table in tables:
|
||||
table.drop()
|
@ -1,60 +0,0 @@
|
||||
# Copyright (c) 2013 The Johns Hopkins University/Applied Physics Laboratory
|
||||
# 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 Column, ForeignKey, MetaData, Table
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String
|
||||
|
||||
|
||||
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))
|
||||
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))
|
||||
snapshots.create_column(encryption_key)
|
||||
volume_type = Column('volume_type_id', String(36))
|
||||
snapshots.create_column(volume_type)
|
||||
|
||||
volume_types = Table('volume_types', meta, autoload=True)
|
||||
|
||||
# encryption types associated with particular volume type
|
||||
encryption = Table(
|
||||
'encryption', 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('cipher', String(length=255)),
|
||||
Column('control_location', String(length=255), nullable=False),
|
||||
Column('key_size', Integer),
|
||||
Column('provider', String(length=255), nullable=False),
|
||||
# NOTE(joel-coffman): The volume_type_id must be unique or else the
|
||||
# referenced volume type becomes ambiguous. That is, specifying the
|
||||
# volume type is not sufficient to identify a particular encryption
|
||||
# scheme unless each volume type is associated with at most one
|
||||
# encryption scheme.
|
||||
Column('volume_type_id', String(length=36),
|
||||
ForeignKey(volume_types.c.id),
|
||||
primary_key=True, nullable=False),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
encryption.create()
|
@ -1,48 +0,0 @@
|
||||
# Copyright (C) 2013 eBay Inc.
|
||||
# Copyright (C) 2013 OpenStack Foundation
|
||||
# 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 Boolean, Column, DateTime
|
||||
from sqlalchemy import ForeignKey, MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add volume_type_rate_limit table."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
quality_of_service_specs = Table(
|
||||
'quality_of_service_specs', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('specs_id', String(36),
|
||||
ForeignKey('quality_of_service_specs.id')),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
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'))
|
||||
|
||||
volume_types.create_column(qos_specs_id)
|
||||
volume_types.update().values(qos_specs_id=None).execute()
|
@ -1,26 +0,0 @@
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# 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 String, Column, MetaData, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add migration_status column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
migration_status = Column('migration_status', String(255))
|
||||
volumes.create_column(migration_status)
|
@ -1,39 +0,0 @@
|
||||
# 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
|
||||
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
Table('volumes', meta, autoload=True)
|
||||
|
||||
# New table
|
||||
volume_admin_metadata = Table(
|
||||
'volume_admin_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_id', String(length=36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('key', String(length=255)),
|
||||
Column('value', String(length=255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
volume_admin_metadata.create()
|
@ -1,66 +0,0 @@
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_config import cfg
|
||||
from sqlalchemy import MetaData, Table
|
||||
|
||||
# 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_volumes', 'cinder.quota')
|
||||
CONF.import_opt('quota_snapshots', 'cinder.quota')
|
||||
CONF.import_opt('quota_gigabytes', 'cinder.quota')
|
||||
|
||||
CLASS_NAME = 'default'
|
||||
CREATED_AT = datetime.datetime.now() # noqa
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add default quota class data into DB."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
quota_classes = Table('quota_classes', meta, autoload=True)
|
||||
|
||||
rows = quota_classes.count().\
|
||||
where(quota_classes.c.class_name == 'default').execute().scalar()
|
||||
|
||||
# Do not add entries if there are already 'default' entries. We don't
|
||||
# want to write over something the user added.
|
||||
if rows:
|
||||
return
|
||||
|
||||
# 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, })
|
@ -1,23 +0,0 @@
|
||||
# Copyright 2013 IBM Corp.
|
||||
#
|
||||
# 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 Column, MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
services = Table('services', meta, autoload=True)
|
||||
reason = Column('disabled_reason', String(255))
|
||||
services.create_column(reason)
|
@ -1,38 +0,0 @@
|
||||
# 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 Index, MetaData, Table
|
||||
|
||||
|
||||
def _get_deleted_expire_index(table):
|
||||
members = sorted(['deleted', 'expire'])
|
||||
for idx in table.indexes:
|
||||
if sorted(idx.columns.keys()) == members:
|
||||
return idx
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
reservations = Table('reservations', meta, autoload=True)
|
||||
if _get_deleted_expire_index(reservations):
|
||||
return
|
||||
|
||||
# Based on expire_reservations query
|
||||
# from: cinder/db/sqlalchemy/api.py
|
||||
index = Index('reservations_deleted_expire_idx',
|
||||
reservations.c.deleted, reservations.c.expire)
|
||||
|
||||
index.create(migrate_engine)
|
@ -1,34 +0,0 @@
|
||||
# Copyright 2014 IBM Corp.
|
||||
#
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add replication columns to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
replication_status = Column('replication_status', String(255))
|
||||
replication_extended_status = Column('replication_extended_status',
|
||||
String(255))
|
||||
replication_driver_data = Column('replication_driver_data', String(255))
|
||||
volumes.create_column(replication_status)
|
||||
volumes.create_column(replication_extended_status)
|
||||
volumes.create_column(replication_driver_data)
|
||||
volumes.update().values(replication_status='disabled',
|
||||
replication_extended_status=None,
|
||||
replication_driver_data=None).execute()
|
@ -1,81 +0,0 @@
|
||||
# Copyright (C) 2012 - 2014 EMC Corporation.
|
||||
# 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 Boolean, Column, DateTime
|
||||
from sqlalchemy import ForeignKey, MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# New table
|
||||
consistencygroups = Table(
|
||||
'consistencygroups', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('user_id', String(length=255)),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('host', String(length=255)),
|
||||
Column('availability_zone', String(length=255)),
|
||||
Column('name', String(length=255)),
|
||||
Column('description', String(length=255)),
|
||||
Column('volume_type_id', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
consistencygroups.create()
|
||||
|
||||
# New table
|
||||
cgsnapshots = Table(
|
||||
'cgsnapshots', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('consistencygroup_id', String(36),
|
||||
ForeignKey('consistencygroups.id'),
|
||||
nullable=False),
|
||||
Column('user_id', String(length=255)),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('name', String(length=255)),
|
||||
Column('description', String(length=255)),
|
||||
Column('status', String(length=255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
cgsnapshots.create()
|
||||
|
||||
# Add column to volumes table
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
consistencygroup_id = Column('consistencygroup_id', String(36),
|
||||
ForeignKey('consistencygroups.id'))
|
||||
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'))
|
||||
|
||||
snapshots.create_column(cgsnapshot_id)
|
||||
snapshots.update().values(cgsnapshot_id=None).execute()
|
@ -1,52 +0,0 @@
|
||||
# Copyright (C) 2012 - 2014 EMC Corporation.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_config import cfg
|
||||
from sqlalchemy import MetaData, Table
|
||||
|
||||
# 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')
|
||||
|
||||
CLASS_NAME = 'default'
|
||||
CREATED_AT = datetime.datetime.now() # noqa
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add default quota class data into DB."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
quota_classes = Table('quota_classes', meta, autoload=True)
|
||||
|
||||
rows = quota_classes.count().\
|
||||
where(quota_classes.c.resource == 'consistencygroups').\
|
||||
execute().scalar()
|
||||
|
||||
# Do not add entries if there are already 'consistencygroups' entries.
|
||||
if rows:
|
||||
return
|
||||
|
||||
# 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, })
|
@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# Do not use this number for new Kilo work. New Kilo work starts after
|
||||
# all the placeholders.
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# Do not use this number for new Kilo work. New Kilo work starts after
|
||||
# all the placeholders.
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# Do not use this number for new Kilo work. New Kilo work starts after
|
||||
# all the placeholders.
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# Do not use this number for new Kilo work. New Kilo work starts after
|
||||
# all the placeholders.
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,19 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# Do not use this number for new Kilo work. New Kilo work starts after
|
||||
# all the placeholders.
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,41 +0,0 @@
|
||||
# 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, UniqueConstraint
|
||||
from sqlalchemy import Integer, MetaData, String, Table, ForeignKey
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
volume_types = Table('volume_types', meta, autoload=True)
|
||||
is_public = Column('is_public', Boolean)
|
||||
|
||||
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,
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('volume_type_id', String(36),
|
||||
ForeignKey('volume_types.id')),
|
||||
Column('project_id', String(length=255)),
|
||||
Column('deleted', Boolean(create_constraint=True, name=None)),
|
||||
UniqueConstraint('volume_type_id', 'project_id', 'deleted'),
|
||||
mysql_engine='InnoDB',
|
||||
)
|
||||
|
||||
volume_type_projects.create()
|
@ -1,95 +0,0 @@
|
||||
# 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.
|
||||
|
||||
import uuid
|
||||
|
||||
from migrate import PrimaryKeyConstraint, ForeignKeyConstraint
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
from sqlalchemy import String, Integer, Boolean, DateTime
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add UUID primary key column to encryption."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
encryptions = Table('encryption', meta, autoload=True)
|
||||
|
||||
# NOTE: SQLite doesn't support 'drop constraint' statament
|
||||
if migrate_engine.name == 'sqlite':
|
||||
_upgrade_sqlite(meta, encryptions)
|
||||
else:
|
||||
encryption_id_column_kwargs = {}
|
||||
if migrate_engine.name == 'ibm_db_sa':
|
||||
# NOTE(junxiebj): DB2 10.5 doesn't support primary key
|
||||
# constraints over nullable columns, so we have to
|
||||
# make the column non-nullable in the DB2 case.
|
||||
encryption_id_column_kwargs['nullable'] = False
|
||||
encryption_id = Column('encryption_id', String(36),
|
||||
**encryption_id_column_kwargs)
|
||||
encryptions.create_column(encryption_id)
|
||||
|
||||
encryption_items = list(encryptions.select().execute())
|
||||
|
||||
for item in encryption_items:
|
||||
encryptions.update().\
|
||||
where(encryptions.c.volume_type_id == item['volume_type_id']).\
|
||||
values(encryption_id=str(uuid.uuid4())).execute()
|
||||
|
||||
# NOTE (e0ne): need to drop FK first for MySQL
|
||||
if migrate_engine.name == 'mysql':
|
||||
ref_table = Table('volume_types', meta, autoload=True)
|
||||
params = {'columns': [encryptions.c['volume_type_id']],
|
||||
'refcolumns': [ref_table.c['id']],
|
||||
'name': 'encryption_ibfk_1'}
|
||||
volume_type_fk = ForeignKeyConstraint(**params)
|
||||
volume_type_fk.drop()
|
||||
|
||||
volume_type_pk = PrimaryKeyConstraint('volume_type_id',
|
||||
table=encryptions)
|
||||
volume_type_pk.drop()
|
||||
|
||||
pkey = PrimaryKeyConstraint(encryptions.columns.encryption_id)
|
||||
pkey.create()
|
||||
|
||||
|
||||
def _upgrade_sqlite(meta, encryptions):
|
||||
new_encryptions = Table(
|
||||
'encryption_33', 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('cipher', String(255)),
|
||||
Column('key_size', Integer),
|
||||
Column('provider', String(255)),
|
||||
Column('control_location', String(255)),
|
||||
Column('encryption_id', String(36), primary_key=True),
|
||||
Column('volume_type_id', String(36))
|
||||
)
|
||||
new_encryptions.create()
|
||||
encryption_items = list(encryptions.select().execute())
|
||||
for item in encryption_items:
|
||||
new_encryptions.insert().\
|
||||
values(created_at=item['created_at'],
|
||||
updated_at=item['updated_at'],
|
||||
deleted_at=item['deleted_at'],
|
||||
deleted=item['deleted'],
|
||||
cipher=item['cipher'],
|
||||
key_size=item['key_size'],
|
||||
provider=item['provider'],
|
||||
control_location=item['control_location'],
|
||||
encryption_id=str(uuid.uuid4()),
|
||||
volume_type_id=item['volume_type_id']).execute()
|
||||
|
||||
encryptions.drop()
|
||||
new_encryptions.rename('encryption')
|
@ -1,25 +0,0 @@
|
||||
# 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 Column, MetaData, Table, String
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add description column to volume_types."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volume_types = Table('volume_types', meta, autoload=True)
|
||||
description = Column('description', String(255))
|
||||
volume_types.create_column(description)
|
||||
volume_types.update().values(description=None).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add provider_id column to volumes."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
provider_id = Column('provider_id', String(255))
|
||||
volumes.create_column(provider_id)
|
||||
volumes.update().values(provider_id=None).execute()
|
@ -1,25 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add provider_id column to snapshots."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
snapshots = Table('snapshots', meta, autoload=True)
|
||||
provider_id = Column('provider_id', String(255))
|
||||
snapshots.create_column(provider_id)
|
||||
snapshots.update().values(provider_id=None).execute()
|
@ -1,26 +0,0 @@
|
||||
# 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 Column
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add cgsnapshot_id column to consistencygroups."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
consistencygroups = Table('consistencygroups', meta, autoload=True)
|
||||
cgsnapshot_id = Column('cgsnapshot_id', String(36))
|
||||
|
||||
consistencygroups.create_column(cgsnapshot_id)
|
||||
consistencygroups.update().values(cgsnapshot_id=None).execute()
|
@ -1,36 +0,0 @@
|
||||
# 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 Column, DateTime, Integer
|
||||
from sqlalchemy import MetaData, String, Table, UniqueConstraint
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# New table
|
||||
initiator_data = Table(
|
||||
'driver_initiator_data', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('initiator', String(length=255), index=True, nullable=False),
|
||||
Column('namespace', String(length=255), nullable=False),
|
||||
Column('key', String(length=255), nullable=False),
|
||||
Column('value', String(length=255)),
|
||||
UniqueConstraint('initiator', 'namespace', 'key'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
initiator_data.create()
|
@ -1,28 +0,0 @@
|
||||
# Copyright 2014 TrilioData, Inc
|
||||
# Copyright (c) 2015 EMC Corporation
|
||||
# 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 Column, MetaData, String, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
backups = Table('backups', meta, autoload=True)
|
||||
parent_id = Column('parent_id', String(length=36))
|
||||
|
||||
backups.create_column(parent_id)
|
||||
backups.update().values(parent_id=None).execute()
|
@ -1,88 +0,0 @@
|
||||
# (c) Copyright 2012-2014 Hewlett-Packard Development Company, L.P.
|
||||
# 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.
|
||||
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import six
|
||||
from sqlalchemy import Boolean, Column, DateTime
|
||||
from sqlalchemy import ForeignKey, MetaData, String, Table
|
||||
|
||||
CREATED_AT = datetime.datetime.now() # noqa
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""Add volume multi attachment table."""
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# add the multiattach flag to the volumes table.
|
||||
volumes = Table('volumes', meta, autoload=True)
|
||||
multiattach = Column('multiattach', Boolean)
|
||||
volumes.create_column(multiattach)
|
||||
volumes.update().values(multiattach=False).execute()
|
||||
|
||||
# The new volume_attachment table
|
||||
volume_attachment = Table(
|
||||
'volume_attachment', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(length=36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(length=36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('attached_host', String(length=255)),
|
||||
Column('instance_uuid', String(length=36)),
|
||||
Column('mountpoint', String(length=255)),
|
||||
Column('attach_time', DateTime),
|
||||
Column('detach_time', DateTime),
|
||||
Column('attach_mode', String(length=36)),
|
||||
Column('attach_status', String(length=255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_attachment.create()
|
||||
|
||||
# now migrate existing volume attachment info into the
|
||||
# new volume_attachment table
|
||||
volumes_list = list(volumes.select().execute())
|
||||
for volume in volumes_list:
|
||||
if volume.attach_status == 'attached':
|
||||
attachment = volume_attachment.insert()
|
||||
values = {'id': six.text_type(uuid.uuid4()),
|
||||
'created_at': CREATED_AT,
|
||||
'deleted_at': None,
|
||||
'deleted': False,
|
||||
'volume_id': volume.id,
|
||||
'attached_host': volume.host,
|
||||
'instance_uuid': volume.instance_uuid,
|
||||
'mountpoint': volume.mountpoint,
|
||||
'attach_time': volume.attach_time,
|
||||
'attach_mode': 'rw',
|
||||
'attach_status': 'attached',
|
||||
}
|
||||
attachment.execute(values)
|
||||
|
||||
# we have no reason to keep the columns that now
|
||||
# exist in the volume_attachment table
|
||||
mountpoint = volumes.columns.mountpoint
|
||||
volumes.drop_column(mountpoint)
|
||||
instance_uuid = volumes.columns.instance_uuid
|
||||
volumes.drop_column(instance_uuid)
|
||||
attach_time = volumes.columns.attach_time
|
||||
volumes.drop_column(attach_time)
|
||||
attached_host = volumes.columns.attached_host
|
||||
volumes.drop_column(attached_host)
|
@ -1,21 +0,0 @@
|
||||
# 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 Column, MetaData, DateTime, Table
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
services = Table('services', meta, autoload=True)
|
||||
modified_at = Column('modified_at', DateTime(timezone=False))
|
||||
services.create_column(modified_at)
|
@ -1,22 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# This is a placeholder for Kilo backports.
|
||||
# Do not use this number for new Liberty work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,22 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# This is a placeholder for Kilo backports.
|
||||
# Do not use this number for new Liberty work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,22 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# This is a placeholder for Kilo backports.
|
||||
# Do not use this number for new Liberty work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -1,22 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# This is a placeholder for Kilo backports.
|
||||
# Do not use this number for new Liberty work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
553
cinder/db/sqlalchemy/migrate_repo/versions/046_cinder_init.py
Normal file
553
cinder/db/sqlalchemy/migrate_repo/versions/046_cinder_init.py
Normal file
@ -0,0 +1,553 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_config import cfg
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Index
|
||||
from sqlalchemy import Integer, MetaData, String, Table, Text, UniqueConstraint
|
||||
|
||||
# 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_volumes', 'cinder.quota')
|
||||
CONF.import_opt('quota_snapshots', 'cinder.quota')
|
||||
CONF.import_opt('quota_gigabytes', 'cinder.quota')
|
||||
CONF.import_opt('quota_consistencygroups', 'cinder.quota')
|
||||
|
||||
CLASS_NAME = 'default'
|
||||
CREATED_AT = datetime.datetime.now() # noqa
|
||||
|
||||
|
||||
def define_tables(meta):
|
||||
services = Table(
|
||||
'services', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('host', String(255)),
|
||||
Column('binary', String(255)),
|
||||
Column('topic', String(255)),
|
||||
Column('report_count', Integer, nullable=False),
|
||||
Column('disabled', Boolean),
|
||||
Column('availability_zone', String(255)),
|
||||
Column('disabled_reason', String(255)),
|
||||
Column('modified_at', DateTime(timezone=False)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
consistencygroups = Table(
|
||||
'consistencygroups', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('user_id', String(255)),
|
||||
Column('project_id', String(255)),
|
||||
Column('host', String(255)),
|
||||
Column('availability_zone', String(255)),
|
||||
Column('name', String(255)),
|
||||
Column('description', String(255)),
|
||||
Column('volume_type_id', String(255)),
|
||||
Column('status', String(255)),
|
||||
Column('cgsnapshot_id', String(36)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
cgsnapshots = Table(
|
||||
'cgsnapshots', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('consistencygroup_id', String(36),
|
||||
ForeignKey('consistencygroups.id'),
|
||||
nullable=False),
|
||||
Column('user_id', String(255)),
|
||||
Column('project_id', String(255)),
|
||||
Column('name', String(255)),
|
||||
Column('description', String(255)),
|
||||
Column('status', String(255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
volumes = Table(
|
||||
'volumes', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('ec2_id', String(255)),
|
||||
Column('user_id', String(255)),
|
||||
Column('project_id', String(255)),
|
||||
Column('host', String(255)),
|
||||
Column('size', Integer),
|
||||
Column('availability_zone', String(255)),
|
||||
Column('status', String(255)),
|
||||
Column('attach_status', String(255)),
|
||||
Column('scheduled_at', DateTime),
|
||||
Column('launched_at', DateTime),
|
||||
Column('terminated_at', DateTime),
|
||||
Column('display_name', String(255)),
|
||||
Column('display_description', String(255)),
|
||||
Column('provider_location', String(256)),
|
||||
Column('provider_auth', String(256)),
|
||||
Column('snapshot_id', String(36)),
|
||||
Column('volume_type_id', String(36)),
|
||||
Column('source_volid', String(36)),
|
||||
Column('bootable', Boolean),
|
||||
Column('provider_geometry', String(255)),
|
||||
Column('_name_id', String(36)),
|
||||
Column('encryption_key_id', String(36)),
|
||||
Column('migration_status', String(255)),
|
||||
Column('replication_status', String(255)),
|
||||
Column('replication_extended_status', String(255)),
|
||||
Column('replication_driver_data', String(255)),
|
||||
Column('consistencygroup_id', String(36),
|
||||
ForeignKey('consistencygroups.id')),
|
||||
Column('provider_id', String(255)),
|
||||
Column('multiattach', Boolean),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_attachment = Table(
|
||||
'volume_attachment', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('attached_host', String(255)),
|
||||
Column('instance_uuid', String(36)),
|
||||
Column('mountpoint', String(255)),
|
||||
Column('attach_time', DateTime),
|
||||
Column('detach_time', DateTime),
|
||||
Column('attach_mode', String(36)),
|
||||
Column('attach_status', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
snapshots = Table(
|
||||
'snapshots', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id')),
|
||||
Column('user_id', String(255)),
|
||||
Column('project_id', String(255)),
|
||||
Column('status', String(255)),
|
||||
Column('progress', String(255)),
|
||||
Column('volume_size', Integer),
|
||||
Column('scheduled_at', DateTime),
|
||||
Column('display_name', String(255)),
|
||||
Column('display_description', String(255)),
|
||||
Column('provider_location', String(255)),
|
||||
Column('encryption_key_id', String(36)),
|
||||
Column('volume_type_id', String(36)),
|
||||
Column('cgsnapshot_id', String(36),
|
||||
ForeignKey('cgsnapshots.id')),
|
||||
Column('provider_id', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
snapshot_metadata = Table(
|
||||
'snapshot_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('snapshot_id', String(36), ForeignKey('snapshots.id'),
|
||||
nullable=False),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
quality_of_service_specs = Table(
|
||||
'quality_of_service_specs', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('specs_id', String(36),
|
||||
ForeignKey('quality_of_service_specs.id')),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
volume_types = Table(
|
||||
'volume_types', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('name', String(255)),
|
||||
Column('qos_specs_id', String(36),
|
||||
ForeignKey('quality_of_service_specs.id')),
|
||||
Column('is_public', Boolean),
|
||||
Column('description', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_type_projects = Table(
|
||||
'volume_type_projects', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('volume_type_id', String(36),
|
||||
ForeignKey('volume_types.id')),
|
||||
Column('project_id', String(255)),
|
||||
Column('deleted', Boolean(create_constraint=True, name=None)),
|
||||
UniqueConstraint('volume_type_id', 'project_id', 'deleted'),
|
||||
mysql_engine='InnoDB',
|
||||
)
|
||||
|
||||
volume_metadata = Table(
|
||||
'volume_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
volume_type_extra_specs = Table(
|
||||
'volume_type_extra_specs', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_type_id', String(36),
|
||||
ForeignKey('volume_types.id'), nullable=False),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
quotas = Table(
|
||||
'quotas', meta,
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('project_id', String(255)),
|
||||
Column('resource', String(255), nullable=False),
|
||||
Column('hard_limit', Integer),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
iscsi_targets = Table(
|
||||
'iscsi_targets', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('target_num', Integer),
|
||||
Column('host', String(255)),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id'),
|
||||
nullable=True),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
quota_classes = Table(
|
||||
'quota_classes', 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),
|
||||
Column('class_name', String(255), index=True),
|
||||
Column('resource', String(255)),
|
||||
Column('hard_limit', Integer(), nullable=True),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
quota_usages = Table(
|
||||
'quota_usages', 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),
|
||||
Column('project_id', String(255), index=True),
|
||||
Column('resource', String(255)),
|
||||
Column('in_use', Integer(), nullable=False),
|
||||
Column('reserved', Integer(), nullable=False),
|
||||
Column('until_refresh', Integer(), nullable=True),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
reservations = Table(
|
||||
'reservations', 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),
|
||||
Column('uuid', String(36), nullable=False),
|
||||
Column('usage_id',
|
||||
Integer(),
|
||||
ForeignKey('quota_usages.id'),
|
||||
nullable=False),
|
||||
Column('project_id', String(255), index=True),
|
||||
Column('resource', String(255)),
|
||||
Column('delta', Integer(), nullable=False),
|
||||
Column('expire', DateTime(timezone=False)),
|
||||
Index('reservations_deleted_expire_idx',
|
||||
'deleted', 'expire'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8',
|
||||
)
|
||||
|
||||
volume_glance_metadata = Table(
|
||||
'volume_glance_metadata',
|
||||
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('volume_id', String(36), ForeignKey('volumes.id')),
|
||||
Column('snapshot_id', String(36),
|
||||
ForeignKey('snapshots.id')),
|
||||
Column('key', String(255)),
|
||||
Column('value', Text),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
backups = Table(
|
||||
'backups', 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', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), nullable=False),
|
||||
Column('user_id', String(255)),
|
||||
Column('project_id', String(255)),
|
||||
Column('host', String(255)),
|
||||
Column('availability_zone', String(255)),
|
||||
Column('display_name', String(255)),
|
||||
Column('display_description', String(255)),
|
||||
Column('container', String(255)),
|
||||
Column('status', String(255)),
|
||||
Column('fail_reason', String(255)),
|
||||
Column('service_metadata', String(255)),
|
||||
Column('service', String(255)),
|
||||
Column('size', Integer()),
|
||||
Column('object_count', Integer()),
|
||||
Column('parent_id', String(36)),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
|
||||
transfers = Table(
|
||||
'transfers', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('deleted_at', DateTime(timezone=False)),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('display_name', String(255)),
|
||||
Column('salt', String(255)),
|
||||
Column('crypt_hash', String(255)),
|
||||
Column('expires_at', DateTime(timezone=False)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
# Sqlite needs to handle nullable differently
|
||||
is_nullable = (meta.bind.name == 'sqlite')
|
||||
|
||||
encryption = Table(
|
||||
'encryption', 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('cipher', String(255)),
|
||||
Column('control_location', String(255), nullable=is_nullable),
|
||||
Column('key_size', Integer),
|
||||
Column('provider', String(255), nullable=is_nullable),
|
||||
# NOTE(joel-coffman): The volume_type_id must be unique or else the
|
||||
# referenced volume type becomes ambiguous. That is, specifying the
|
||||
# volume type is not sufficient to identify a particular encryption
|
||||
# scheme unless each volume type is associated with at most one
|
||||
# encryption scheme.
|
||||
Column('volume_type_id', String(36),
|
||||
ForeignKey('volume_types.id')),
|
||||
Column('encryption_id', String(36), primary_key=True, nullable=False),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
volume_admin_metadata = Table(
|
||||
'volume_admin_metadata', meta,
|
||||
Column('created_at', DateTime),
|
||||
Column('updated_at', DateTime),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('volume_id', String(36), ForeignKey('volumes.id'),
|
||||
nullable=False),
|
||||
Column('key', String(255)),
|
||||
Column('value', String(255)),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
initiator_data = Table(
|
||||
'driver_initiator_data', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('id', Integer, primary_key=True, nullable=False),
|
||||
Column('initiator', String(255), index=True, nullable=False),
|
||||
Column('namespace', String(255), nullable=False),
|
||||
Column('key', String(255), nullable=False),
|
||||
Column('value', String(255)),
|
||||
UniqueConstraint('initiator', 'namespace', 'key'),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
return [consistencygroups,
|
||||
cgsnapshots,
|
||||
volumes,
|
||||
volume_attachment,
|
||||
snapshots,
|
||||
snapshot_metadata,
|
||||
quality_of_service_specs,
|
||||
volume_types,
|
||||
volume_type_projects,
|
||||
iscsi_targets,
|
||||
quotas,
|
||||
services,
|
||||
volume_metadata,
|
||||
volume_type_extra_specs,
|
||||
quota_classes,
|
||||
quota_usages,
|
||||
reservations,
|
||||
volume_glance_metadata,
|
||||
backups,
|
||||
transfers,
|
||||
encryption,
|
||||
volume_admin_metadata,
|
||||
initiator_data]
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
# create all tables
|
||||
# Take care on create order for those with FK dependencies
|
||||
tables = define_tables(meta)
|
||||
|
||||
for table in tables:
|
||||
table.create()
|
||||
|
||||
if migrate_engine.name == "mysql":
|
||||
tables = ["consistencygroups",
|
||||
"cgsnapshots",
|
||||
"snapshots",
|
||||
"snapshot_metadata",
|
||||
"quality_of_service_specs",
|
||||
"volume_types",
|
||||
"volume_type_projects",
|
||||
"volumes",
|
||||
"volume_attachment",
|
||||
"iscsi_targets",
|
||||
"migrate_version",
|
||||
"quotas",
|
||||
"services",
|
||||
"volume_metadata",
|
||||
"volume_type_extra_specs",
|
||||
"quota_classes",
|
||||
"quota_usages",
|
||||
"reservations",
|
||||
"volume_glance_metadata",
|
||||
"backups",
|
||||
"transfers",
|
||||
"encryption",
|
||||
"volume_admin_metadata",
|
||||
"driver_initiator_data"]
|
||||
|
||||
migrate_engine.execute("SET foreign_key_checks = 0")
|
||||
for table in tables:
|
||||
migrate_engine.execute(
|
||||
"ALTER TABLE %s CONVERT TO CHARACTER SET utf8" % table)
|
||||
migrate_engine.execute("SET foreign_key_checks = 1")
|
||||
migrate_engine.execute(
|
||||
"ALTER DATABASE %s DEFAULT CHARACTER SET utf8" %
|
||||
migrate_engine.url.database)
|
||||
migrate_engine.execute("ALTER TABLE %s Engine=InnoDB" % table)
|
||||
|
||||
# Set default quota class values
|
||||
quota_classes = Table('quota_classes', meta, autoload=True)
|
||||
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, })
|
||||
qci.execute({'created_at': CREATED_AT,
|
||||
'class_name': CLASS_NAME,
|
||||
'resource': 'consistencygroups',
|
||||
'hard_limit': CONF.quota_consistencygroups,
|
||||
'deleted': False, })
|
@ -1,22 +0,0 @@
|
||||
# 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.
|
||||
|
||||
# This is a placeholder for Kilo backports.
|
||||
# Do not use this number for new Liberty work. New work starts after
|
||||
# all the placeholders.
|
||||
#
|
||||
# See this for more information:
|
||||
# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
pass
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
upgrade:
|
||||
- The Cinder database can now only be upgraded from changes since the Kilo
|
||||
release. In order to upgrade from a version prior to that, you must now
|
||||
upgrade to at least Kilo first, then to Newton or later.
|
Loading…
x
Reference in New Issue
Block a user