This patchset is for bug:
24394534 Mitaka Glance should support MySQL Cluster
This fixes the following aspects of Glance:
1. Implementation of an oslo.db configuration parameter to specify the MySQL
storage engine (mysql_storage_engine).
2. Replacement of hardcoded SQL statements that set the engine to "InnoDB"
to the above configuration value.
3. Logic to handle SQL differences between MySQL InnoDB and MySQL Cluster (NDB).
This includes column lengths, constraints, foreign keys, and indexes.
This has not been committed upstream, but has been filed in launchpad:
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/001_add_images_table.py.orig 2016-08-10 09:36:22.622664972 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/001_add_images_table.py 2016-08-10 09:34:27.421171908 -0700
@@ -13,11 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (Column, MetaData, Table)
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, Text, create_tables, drop_tables) # noqa
+CONF = cfg.CONF
+
def define_images_table(meta):
images = Table('images',
@@ -41,7 +44,7 @@ def define_images_table(meta):
nullable=False,
default=False,
index=True),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/002_add_image_properties_table.py.orig 2016-08-10 09:36:22.630165670 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/002_add_image_properties_table.py 2016-08-10 09:34:27.422389893 -0700
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (
Column, ForeignKey, Index, MetaData, Table, UniqueConstraint)
@@ -20,6 +21,8 @@ from glance.db.sqlalchemy.migrate_repo.s
Boolean, DateTime, Integer, String, Text, create_tables, drop_tables,
from_migration_import) # noqa
+CONF = cfg.CONF
+
def define_image_properties_table(meta):
(define_images_table,) = from_migration_import(
@@ -44,7 +47,8 @@ def define_image_properties_table(meta):
nullable=False),
Column('image_id',
Integer(),
- ForeignKey('images.id'),
+ ForeignKey('images.id',
+ name='image_properties_ibfk_1'),
nullable=False,
index=True),
Column('key', String(255), nullable=False),
@@ -59,7 +63,7 @@ def define_image_properties_table(meta):
index=True),
UniqueConstraint('image_id', 'key',
**constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/003_add_disk_format.py.orig 2016-08-10 09:36:22.637028552 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/003_add_disk_format.py 2016-08-10 09:34:27.423147663 -0700
@@ -14,11 +14,14 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -47,7 +50,7 @@ def get_images_table(meta):
nullable=False,
default=False,
index=True),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return images
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/004_add_checksum.py.orig 2016-08-10 09:36:22.643321775 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/004_add_checksum.py 2016-08-10 09:34:27.423839815 -0700
@@ -14,11 +14,14 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -48,7 +51,7 @@ def get_images_table(meta):
default=False,
index=True),
Column('checksum', String(32)),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return images
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/005_size_big_integer.py.orig 2016-08-10 09:36:22.650608190 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/005_size_big_integer.py 2016-08-10 09:34:27.424528158 -0700
@@ -14,12 +14,15 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, BigInteger, Integer, String,
Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -48,7 +51,7 @@ def get_images_table(meta):
nullable=False,
default=False,
index=True),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return images
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/006_key_to_name.py.orig 2016-08-10 09:36:22.657538722 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/006_key_to_name.py 2016-08-10 09:34:27.425360155 -0700
@@ -14,11 +14,14 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -49,7 +52,8 @@ def get_image_properties_table(meta):
nullable=False),
Column('image_id',
Integer(),
- ForeignKey('images.id'),
+ ForeignKey('images.id',
+ name='image_properties_ibfk_1'),
nullable=False,
index=True),
Column('name', String(255), nullable=False),
@@ -63,7 +67,7 @@ def get_image_properties_table(meta):
default=False,
index=True),
UniqueConstraint('image_id', 'name'),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return image_properties
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/007_add_owner.py.orig 2016-08-10 09:36:22.664818540 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/007_add_owner.py 2016-08-10 09:34:27.427318330 -0700
@@ -14,12 +14,15 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, BigInteger, Integer, String,
Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -50,7 +53,7 @@ def get_images_table(meta):
index=True),
Column('checksum', String(32)),
Column('owner', String(255)),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return images
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/008_add_image_members_table.py.orig 2016-08-10 09:36:22.672154268 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/008_add_image_members_table.py 2016-08-10 09:34:27.428348883 -0700
@@ -14,12 +14,15 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, create_tables,
drop_tables, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -54,7 +57,8 @@ def get_image_members_table(meta):
nullable=False),
Column('image_id',
Integer(),
- ForeignKey('images.id'),
+ ForeignKey('images.id',
+ name='image_members_image_id_fkey'),
nullable=False,
index=True),
Column('member', String(255), nullable=False),
@@ -72,7 +76,7 @@ def get_image_members_table(meta):
index=True),
UniqueConstraint('image_id', 'member'),
mysql_charset='utf8',
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
# DB2: an index has already been created for the UniqueConstraint option
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/009_add_mindisk_and_minram.py.orig 2016-08-10 09:36:22.678770092 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/009_add_mindisk_and_minram.py 2016-08-10 09:34:27.454363865 -0700
@@ -14,11 +14,14 @@
# under the License.
from migrate.changeset import * # noqa
+from oslo_config import cfg
from sqlalchemy import * # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
+CONF = cfg.CONF
+
def get_images_table(meta):
"""
@@ -51,7 +54,7 @@ def get_images_table(meta):
Column('owner', String(255)),
Column('min_disk', Integer(), default=0),
Column('min_ram', Integer(), default=0),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
extend_existing=True)
return images
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/014_add_image_tags_table.py.orig 2016-08-10 09:36:22.685172827 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/014_add_image_tags_table.py 2016-08-10 09:34:27.456082973 -0700
@@ -13,10 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy import schema
from glance.db.sqlalchemy.migrate_repo import schema as glance_schema
+CONF = cfg.CONF
+
def define_image_tags_table(meta):
# Load the images table so the foreign key can be set up properly
@@ -30,7 +33,8 @@ def define_image_tags_table(meta):
nullable=False),
schema.Column('image_id',
glance_schema.String(36),
- schema.ForeignKey('images.id'),
+ name='image_tags_ibfk_1'),
nullable=False),
schema.Column('value',
glance_schema.String(255),
@@ -46,7 +50,7 @@ def define_image_tags_table(meta):
nullable=False,
default=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8')
schema.Index('ix_image_tags_image_id',
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/018_add_image_locations_table.py.orig 2016-08-10 09:36:22.691935092 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/018_add_image_locations_table.py 2016-08-10 09:34:27.457534530 -0700
@@ -13,10 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
import sqlalchemy
from glance.db.sqlalchemy.migrate_repo import schema
+CONF = cfg.CONF
+
def upgrade(migrate_engine):
meta = sqlalchemy.schema.MetaData(migrate_engine)
@@ -32,7 +35,8 @@ def upgrade(migrate_engine):
nullable=False),
sqlalchemy.Column('image_id',
schema.String(36),
+ name='image_locations_ibfk_1'),
nullable=False,
index=True),
sqlalchemy.Column('value',
@@ -50,7 +54,7 @@ def upgrade(migrate_engine):
nullable=False,
default=False,
index=True),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/021_set_engine_mysql_innodb.py.orig 2016-08-10 09:36:22.698690410 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/021_set_engine_mysql_innodb.py 2016-08-10 09:34:27.458291445 -0700
@@ -14,21 +14,24 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy import MetaData
tables = ['image_locations']
+CONF = cfg.CONF
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
if migrate_engine.name == "mysql":
- d = migrate_engine.execute("SHOW TABLE STATUS WHERE Engine!='InnoDB';")
+ d = migrate_engine.execute("SHOW TABLE STATUS WHERE Engine!='%s';" %
for row in d.fetchall():
table_name = row[0]
if table_name in tables:
- migrate_engine.execute("ALTER TABLE %s Engine=InnoDB" %
- table_name)
+ migrate_engine.execute("ALTER TABLE %(db_table)s Engine=%(mysql_storage_engine)s" %
+ dict(db_table=table_name, mysql_storage_engine=CONF.database.mysql_storage_engine))
def downgrade(migrate_engine):
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/022_image_member_index.py.orig 2016-08-10 09:36:22.705922240 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/022_image_member_index.py 2016-08-10 09:34:27.459101595 -0700
@@ -15,6 +15,7 @@
import re
+from migrate.changeset.constraint import ForeignKeyConstraint
from migrate.changeset import UniqueConstraint
from oslo_db import exception as db_exception
from sqlalchemy import and_, func, orm
@@ -28,6 +29,12 @@ ORIGINAL_KEYNAME_RE = re.compile('image_
def upgrade(migrate_engine):
image_members = _get_image_members_table(migrate_engine)
+ images = _get_images_table(migrate_engine)
+ # Drop foreign key first
+ fkc = ForeignKeyConstraint([image_members.c.image_id],
+ [images.c.id],
+ name='image_members_image_id_fkey')
+ fkc.drop()
if migrate_engine.name in ('mysql', 'postgresql'):
try:
@@ -44,6 +51,9 @@ def upgrade(migrate_engine):
name=NEW_KEYNAME,
table=image_members).create()
+ # Add foreign key back
+ fkc.create()
+
def downgrade(migrate_engine):
image_members = _get_image_members_table(migrate_engine)
@@ -65,6 +75,12 @@ def _get_image_members_table(migrate_eng
return Table('image_members', meta, autoload=True)
+def _get_images_table(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+ return Table('images', meta, autoload=True)
+
+
def _get_original_keyname(db):
return {'mysql': 'image_id',
'postgresql': 'image_members_image_id_member_key'}[db]
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/030_add_tasks_table.py.orig 2016-08-10 09:36:22.712553022 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/030_add_tasks_table.py 2016-08-10 09:34:27.460669890 -0700
@@ -14,11 +14,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (Column, MetaData, Table, Index)
from glance.db.sqlalchemy.migrate_repo.schema import (
Boolean, DateTime, String, Text, create_tables, drop_tables) # noqa
+CONF = cfg.CONF
+
def define_tasks_table(meta):
tasks = Table('tasks',
@@ -38,7 +41,7 @@ def define_tasks_table(meta):
Boolean(),
nullable=False,
default=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/032_add_task_info_table.py.orig 2016-08-10 09:36:22.719716648 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/032_add_task_info_table.py 2016-08-10 09:34:27.471154455 -0700
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (Column, ForeignKey, MetaData, Table)
from glance.db.sqlalchemy.migrate_repo.schema import (String,
@@ -21,6 +22,7 @@ from glance.db.sqlalchemy.migrate_repo.s
drop_tables) # noqa
TASKS_MIGRATE_COLUMNS = ['input', 'message', 'result']
+CONF = cfg.CONF
def define_task_info_table(meta):
@@ -31,13 +33,14 @@ def define_task_info_table(meta):
task_info = Table('task_info',
meta,
Column('task_id', String(36),
- ForeignKey('tasks.id'),
+ ForeignKey('tasks.id',
+ name='task_info_ibfk_1'),
primary_key=True,
nullable=False),
Column('input', Text()),
Column('result', Text()),
Column('message', Text()),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8')
return task_info
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py.orig 2016-08-10 09:36:22.726515825 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/035_add_metadef_tables.py 2016-08-10 09:34:27.472707375 -0700
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
import sqlalchemy
from sqlalchemy.schema import (
Column, ForeignKey, Index, MetaData, Table, UniqueConstraint) # noqa
@@ -25,6 +26,7 @@ from glance.db.sqlalchemy.migrate_repo.s
RESOURCE_TYPES = [u'OS::Glance::Image', u'OS::Cinder::Volume',
u'OS::Nova::Flavor', u'OS::Nova::Aggregate',
u'OS::Nova::Server']
+CONF = cfg.CONF
def _get_metadef_resource_types_table(meta):
@@ -65,7 +67,7 @@ def define_metadef_namespaces_table(meta
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime()),
UniqueConstraint('namespace', **_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -85,7 +87,8 @@ def define_metadef_objects_table(meta):
meta,
Column('id', Integer(), primary_key=True, nullable=False),
Column('namespace_id', Integer(),
- ForeignKey('metadef_namespaces.id'),
+ ForeignKey('metadef_namespaces.id',
+ name='metadef_objects_ibfk_1'),
nullable=False),
Column('name', String(80), nullable=False),
Column('description', Text()),
@@ -95,7 +98,7 @@ def define_metadef_objects_table(meta):
Column('updated_at', DateTime()),
UniqueConstraint('namespace_id', 'name',
**_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -117,14 +120,15 @@ def define_metadef_properties_table(meta
'metadef_properties',
meta,
Column('id', Integer(), primary_key=True, nullable=False),
- Column('namespace_id', Integer(), ForeignKey('metadef_namespaces.id'),
+ Column('namespace_id', Integer(), ForeignKey('metadef_namespaces.id',
+ name='metadef_properties_ibfk_1'),
nullable=False),
Column('name', String(80), nullable=False),
Column('schema', Text(), nullable=False),
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime()),
UniqueConstraint('namespace_id', 'name', **_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -151,7 +155,7 @@ def define_metadef_resource_types_table(
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime()),
UniqueConstraint('name', **_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -172,10 +176,12 @@ def define_metadef_namespace_resource_ty
'metadef_namespace_resource_types',
meta,
Column('resource_type_id', Integer(),
- ForeignKey('metadef_resource_types.id'),
+ ForeignKey('metadef_resource_types.id',
+ name='metadef_namespace_resource_types_ibfk_1'),
primary_key=True, nullable=False),
Column('namespace_id', Integer(),
- ForeignKey('metadef_namespaces.id'),
+ ForeignKey('metadef_namespaces.id',
+ name='metadef_namespace_resource_types_ibfk_2'),
primary_key=True, nullable=False),
Column('properties_target', String(80)),
Column('prefix', String(80)),
@@ -183,7 +189,7 @@ def define_metadef_namespace_resource_ty
Column('updated_at', DateTime()),
UniqueConstraint('resource_type_id', 'namespace_id',
**_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/037_add_changes_to_satisfy_models.py.orig 2016-08-10 09:36:22.732852195 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/037_add_changes_to_satisfy_models.py 2016-08-10 09:34:27.473457502 -0700
@@ -81,7 +81,8 @@ def upgrade(migrate_engine):
image_locations = Table('image_locations', meta, autoload=True)
if len(image_locations.foreign_keys) == 0:
migrate_engine.execute(AddConstraint(ForeignKeyConstraint(
- [image_locations.c.image_id], [images.c.id])))
+ name='image_locations_ibfk_1')))
def downgrade(migrate_engine):
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/038_add_metadef_tags_table.py.orig 2016-08-10 09:36:22.739351950 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/038_add_metadef_tags_table.py 2016-08-10 09:34:27.474322102 -0700
@@ -12,12 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (
Column, Index, MetaData, Table, UniqueConstraint) # noqa
from glance.db.sqlalchemy.migrate_repo.schema import (
DateTime, Integer, String, create_tables, drop_tables) # noqa
+CONF = cfg.CONF
+
def define_metadef_tags_table(meta):
_constr_kwargs = {}
@@ -32,7 +35,7 @@ def define_metadef_tags_table(meta):
Column('updated_at', DateTime()),
UniqueConstraint('namespace_id', 'name',
**_constr_kwargs),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=False)
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/039_add_changes_to_satisfy_models_metadef.py.orig 2016-08-10 09:36:22.745773757 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/039_add_changes_to_satisfy_models_metadef.py 2016-08-10 09:41:20.008006522 -0700
@@ -63,15 +63,25 @@ def upgrade(migrate_engine):
else:
Index('ix_namespaces_namespace', metadef_namespaces.c.namespace).drop()
+ # Drop foreign key first
+ name='metadef_objects_ibfk_1')
+ fkc.drop()
+
Index('ix_objects_namespace_id_name', metadef_objects.c.namespace_id,
metadef_objects.c.name).drop()
+ # Add foreign key back
+ fkc.create()
+
Index('ix_metadef_properties_namespace_id_name',
metadef_properties.c.name).drop()
+ name='metadef_tags_ibfk_1')
# `migrate` module removes unique constraint after adding
@@ -88,8 +98,13 @@ def upgrade(migrate_engine):
if meta.bind.name != "ibm_db_sa":
+ name='metadef_tags_ibfk_1')
+ fkc.drop()
Index('ix_tags_namespace_id_name', metadef_tags.c.namespace_id,
metadef_tags.c.name).drop()
+ fkc.create()
Index('ix_metadef_tags_name', metadef_tags.c.name).create()
@@ -120,10 +135,15 @@ def upgrade(migrate_engine):
migrate_engine.execute(DropConstraint(constraint))
+ name='metadef_namespace_resource_types_ibfk_1')
+ fkc.drop()
constraint = UniqueConstraint(metadef_ns_res_types.c.resource_type_id,
name='resource_type_id')
migrate_engine.execute(DropConstraint(constraint))
+ fkc.create()
constraint = UniqueConstraint(metadef_namespaces.c.namespace,
name='namespace')
@@ -251,7 +271,8 @@ def downgrade(migrate_engine):
if migrate_engine.name != 'sqlite':
+ name='metadef_tags_ibfk_1')
fkc.drop()
if meta.bind.name != "ibm_db_sa":
@@ -332,8 +353,8 @@ def downgrade(migrate_engine):
if migrate_engine.name == 'mysql':
fkc = migrate.ForeignKeyConstraint(
- name='metadef_namespace_resource_types_ibfk_2')
+ name='metadef_namespace_resource_types_ibfk_1')
fkc.drop()
Index('ix_metadef_ns_res_types_namespace_id',
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py.orig 2016-08-10 09:42:23.016042269 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/040_add_changes_to_satisfy_metadefs_tags.py 2016-08-10 09:41:29.896233507 -0700
@@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-
+import migrate
import sqlalchemy
from sqlalchemy import (Table, Index)
@@ -20,5 +20,11 @@ def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
metadef_tags = Table('metadef_tags', meta, autoload=True)
+ metadef_namespaces = Table('metadef_namespaces', meta, autoload=True)
+ name='metadef_tags_ibfk_1')
+ fkc.drop()
Index('namespace_id', metadef_tags.c.namespace_id,
metadef_tags.c.name).drop()
+ fkc.create()
--- glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/041_add_artifact_tables.py.orig 2016-08-10 09:36:22.752236945 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/migrate_repo/versions/041_add_artifact_tables.py 2016-08-10 09:34:27.477711872 -0700
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo_config import cfg
from sqlalchemy.schema import (Column, ForeignKey, Index, MetaData, Table)
@@ -19,6 +20,8 @@ from glance.db.sqlalchemy.migrate_repo.s
BigInteger, Boolean, DateTime, Integer, Numeric, String, Text,
create_tables) # noqa
+CONF = cfg.CONF
+
def define_artifacts_table(meta):
artifacts = Table('artifacts',
@@ -43,7 +46,7 @@ def define_artifacts_table(meta):
nullable=False),
Column('deleted_at', DateTime()),
Column('published_at', DateTime()),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -64,12 +67,14 @@ def define_artifact_tags_table(meta):
Column('id', String(36), primary_key=True,
nullable=False),
Column('artifact_id', String(36),
- ForeignKey('artifacts.id'), nullable=False),
+ ForeignKey('artifacts.id',
+ name='artifact_tags_ibfk_1'),
+ nullable=False),
Column('value', String(255), nullable=False),
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime(),
nullable=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -86,13 +91,16 @@ def define_artifact_dependencies_table(m
Column('id', String(36), primary_key=True,
nullable=False),
Column('artifact_source', String(36),
- ForeignKey('artifacts.id'),
+ ForeignKey('artifacts.id',
+ name='artifact_dependencies_ibfk_1'),
nullable=False),
Column('artifact_dest', String(36),
- ForeignKey('artifacts.id'),
+ ForeignKey('artifacts.id',
+ name='artifact_dependencies_ibfk_2'),
nullable=False),
Column('artifact_origin', String(36),
- ForeignKey('artifacts.id'),
+ ForeignKey('artifacts.id',
+ name='artifact_dependencies_ibfk_3'),
nullable=False),
Column('is_direct', Boolean(),
nullable=False),
@@ -102,7 +110,7 @@ def define_artifact_dependencies_table(m
nullable=False),
Column('updated_at', DateTime(),
nullable=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
@@ -124,7 +132,8 @@ def define_artifact_blobs_table(meta):
Column('id', String(36), primary_key=True,
nullable=False),
Column('artifact_id', String(36),
- ForeignKey('artifacts.id'),
+ ForeignKey('artifacts.id',
+ name='artifact_blobs_ibfk_1'),
nullable=False),
Column('size', BigInteger(), nullable=False),
Column('checksum', String(32)),
@@ -134,7 +143,7 @@ def define_artifact_blobs_table(meta):
Column('created_at', DateTime(), nullable=False),
Column('updated_at', DateTime(),
nullable=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
Index('ix_artifact_blobs_artifact_id',
@@ -151,7 +160,8 @@ def define_artifact_properties_table(met
primary_key=True,
nullable=False),
Column('artifact_id', String(36),
- ForeignKey('artifacts.id'),
+ ForeignKey('artifacts.id',
+ name='artifact_properties_ibfk_1'),
nullable=False),
Column('name', String(255),
nullable=False),
@@ -165,7 +175,7 @@ def define_artifact_properties_table(met
Column('updated_at', DateTime(),
nullable=False),
Column('position', Integer()),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
Index('ix_artifact_properties_artifact_id',
@@ -181,7 +191,8 @@ def define_artifact_blob_locations_table
primary_key=True,
nullable=False),
Column('blob_id', String(36),
- ForeignKey('artifact_blobs.id'),
+ ForeignKey('artifact_blobs.id',
+ name='artifact_blob_locations_ibfk_1'),
nullable=False),
Column('value', Text(), nullable=False),
Column('created_at', DateTime(),
@@ -191,7 +202,7 @@ def define_artifact_blob_locations_table
Column('position', Integer()),
Column('status', String(36),
nullable=True),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8',
extend_existing=True)
Index('ix_artifact_blob_locations_blob_id',
--- glance-12.0.0/glance/db/sqlalchemy/models_glare.py.orig 2016-08-10 09:36:22.759461763 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/models_glare.py 2016-08-10 09:34:27.479493197 -0700
@@ -14,6 +14,8 @@
import uuid
+from oslo_config import cfg
+from oslo_db import options
from oslo_db.sqlalchemy import models
from sqlalchemy import BigInteger
from sqlalchemy import Boolean
@@ -35,12 +37,15 @@ from glance.common import timeutils
import glance.glare as ga
BASE = declarative.declarative_base()
+CONF = cfg.CONF
class ArtifactBase(models.ModelBase, models.TimestampMixin):
"""Base class for Artifact Models."""
- __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
+ __table_args__ = {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set([
"created_at", "updated_at"])
@@ -98,7 +103,8 @@ class Artifact(BASE, ArtifactBase):
Index('ix_artifact_state', 'state'),
Index('ix_artifact_owner', 'owner'),
Index('ix_artifact_visibility', 'visibility'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'})
__protected_attributes__ = ArtifactBase.__protected_attributes__.union(
set(['published_at', 'deleted_at']))
@@ -219,7 +225,8 @@ class ArtifactDependency(BASE, ArtifactB
'artifact_dest'),
Index('ix_artifact_dependencies_direct_dependencies',
'artifact_source', 'is_direct'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'})
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
@@ -248,7 +255,8 @@ class ArtifactTag(BASE, ArtifactBase):
__table_args__ = (Index('ix_artifact_tags_artifact_id', 'artifact_id'),
Index('ix_artifact_tags_artifact_id_tag_value',
'artifact_id', 'value'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
@@ -265,7 +273,8 @@ class ArtifactProperty(BASE, ArtifactBas
__table_args__ = (
Index('ix_artifact_properties_artifact_id', 'artifact_id'),
Index('ix_artifact_properties_name', 'name'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
artifact_id = Column(String(36), ForeignKey('artifacts.id'),
@@ -287,7 +296,8 @@ class ArtifactBlob(BASE, ArtifactBase):
__table_args__ = (
Index('ix_artifact_blobs_artifact_id', 'artifact_id'),
Index('ix_artifact_blobs_name', 'name'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
artifact_id = Column(String(36), ForeignKey('artifacts.id'),
@@ -307,7 +317,8 @@ class ArtifactBlobLocation(BASE, Artifac
__tablename__ = 'artifact_blob_locations'
__table_args__ = (Index('ix_artifact_blob_locations_blob_id',
'blob_id'),
- {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'})
+ {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'})
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
--- glance-12.0.0/glance/db/sqlalchemy/models_metadef.py.orig 2016-08-10 09:36:22.766310320 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/models_metadef.py 2016-08-10 09:34:27.480397292 -0700
@@ -16,6 +16,7 @@
SQLAlchemy models for glance metadata schema
"""
+from oslo_config import cfg
from oslo_db.sqlalchemy import models
from sqlalchemy import Boolean
from sqlalchemy import Column
@@ -32,6 +33,8 @@ from sqlalchemy import UniqueConstraint
from glance.common import timeutils
from glance.db.sqlalchemy.models import JSONEncodedDict
+CONF = cfg.CONF
+
class DictionaryBase(models.ModelBase):
metadata = None
@@ -49,7 +52,8 @@ BASE_DICT = declarative_base(cls=Diction
class GlanceMetadefBase(models.TimestampMixin):
"""Base class for Glance Metadef Models."""
- __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
+ __table_args__ = {'mysql_engine': CONF.database.mysql_storage_engine,
+ 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set(["created_at", "updated_at"])
--- glance-12.0.0/glance/db/sqlalchemy/models.py.orig 2016-08-10 09:36:22.773221505 -0700
+++ glance-12.0.0/glance/db/sqlalchemy/models.py 2016-08-10 09:34:27.481259927 -0700
@@ -20,6 +20,7 @@ SQLAlchemy models for glance data
import uuid
+from oslo_config import cfg
from oslo_db.sqlalchemy import models
from oslo_serialization import jsonutils
from sqlalchemy import BigInteger
@@ -41,6 +42,7 @@ from glance.common import timeutils
BASE = declarative_base()
+CONF = cfg.CONF
class JSONEncodedDict(TypeDecorator):
@@ -62,7 +64,7 @@ class JSONEncodedDict(TypeDecorator):
class GlanceBase(models.ModelBase, models.TimestampMixin):
"""Base class for Glance Models."""
- __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}
+ __table_args__ = {'mysql_engine': CONF.database.mysql_storage_engine, 'mysql_charset': 'utf8'}
__table_initialized__ = False
__protected_attributes__ = set([
"created_at", "updated_at", "deleted_at", "deleted"])
--- glance-12.0.0/glance/tests/unit/test_migrations.py.orig 2016-08-10 09:36:22.780385325 -0700
+++ glance-12.0.0/glance/tests/unit/test_migrations.py 2016-08-10 09:34:27.483366399 -0700
@@ -122,7 +122,7 @@ class MigrationsMixin(test_migrations.Wa
nullable=False,
default=False),
- mysql_engine='InnoDB',
+ mysql_engine=CONF.database.mysql_storage_engine,
mysql_charset='utf8')
@@ -1846,10 +1846,11 @@ class TestMysqlMigrations(test_base.MySQ
noninnodb = self.migrate_engine.execute(
"SELECT count(*) "
"FROM information_schema.TABLES "
- "WHERE TABLE_SCHEMA='%s' "
- "AND ENGINE!='InnoDB' "
+ "WHERE TABLE_SCHEMA='%(table_schema)s' "
+ "AND ENGINE!='%(mysql_storage_engine)s' "
"AND TABLE_NAME!='migrate_version'"
+ % dict(table_schema=self.migrate_engine.url.database,
+ mysql_storage_engine=CONF.database.mysql_storage_engine))
count = noninnodb.scalar()
self.assertEqual(0, count, "%d non InnoDB tables created" % count)