Convert volume_type id from int to uuid.
This converts the volume_type id from int to uuid. In addition, this also corrects an issue of deleting volume_types by name. Even though the client/api is taking the id, it was converting to the name of the volume_type for the db access. We also want to continue enforcing that the name is unique on creation so as to avoid any confusion and for clarity in Horizon. The api has also been enhanced to allow you to specify the type by name or by uuid. This does NOT modify the things like the volume details display field (currently shows the type 'name' not 'uuid'), these types of changes will go in to V2 of the API. Implements blueprint vol-type-to-uuid Change-Id: I1c54ff2a1e0c5df5891408fc11b15176db4028c3
This commit is contained in:
committed by
John Griffith
parent
b1e4232996
commit
51a438c8f3
@@ -303,3 +303,33 @@ class TestMigrations(test.TestCase):
|
||||
self.assertEqual(version,
|
||||
migration_api.db_version(engine,
|
||||
TestMigrations.REPOSITORY))
|
||||
|
||||
def test_migration_004(self):
|
||||
"""Test that volume_type_id migration works correctly."""
|
||||
for (key, engine) in self.engines.items():
|
||||
migration_api.version_control(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
migration.INIT_VERSION)
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 3)
|
||||
metadata = sqlalchemy.schema.MetaData()
|
||||
metadata.bind = engine
|
||||
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 4)
|
||||
volumes = sqlalchemy.Table('volumes',
|
||||
metadata,
|
||||
autoload=True)
|
||||
volume_types = sqlalchemy.Table('volume_types',
|
||||
metadata,
|
||||
autoload=True)
|
||||
extra_specs = sqlalchemy.Table('volume_type_extra_specs',
|
||||
metadata,
|
||||
autoload=True)
|
||||
|
||||
self.assertTrue(isinstance(volumes.c.volume_type_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(volume_types.c.id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(extra_specs.c.volume_type_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
|
||||
self.assertTrue(extra_specs.c.volume_type_id.foreign_keys)
|
||||
|
||||
Reference in New Issue
Block a user