Add uuid to migration table
This adds a uuid column to the migration table so that in a subsequent patch we can start using them. Currently we only identify migrations by internal database id, which is not only a problem for cellsv2, but also not sufficient for us to use for making allocations that are owned by a migration process. Related to blueprint migration-allocations Change-Id: I21dd6125094b13922b703caa34dffffab1789e1b
This commit is contained in:
parent
b198ad349a
commit
9611c922ce
|
@ -0,0 +1,27 @@
|
|||
# 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, Column, Table, Index
|
||||
from sqlalchemy import String
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
meta = MetaData(bind=migrate_engine)
|
||||
|
||||
for prefix in ('', 'shadow_'):
|
||||
migrations = Table('%smigrations' % prefix, meta, autoload=True)
|
||||
if not hasattr(migrations.c, 'uuid'):
|
||||
uuid = Column('uuid', String(36))
|
||||
migrations.create_column(uuid)
|
||||
idx = Index('%smigrations_uuid' % prefix,
|
||||
migrations.c.uuid, unique=True)
|
||||
idx.create(migrate_engine)
|
|
@ -752,6 +752,7 @@ class Migration(BASE, NovaBase, models.SoftDeleteMixin):
|
|||
Index('migrations_by_host_nodes_and_status_idx', 'deleted',
|
||||
'source_compute', 'dest_compute', 'source_node', 'dest_node',
|
||||
'status'),
|
||||
Index('migrations_uuid', 'uuid', unique=True),
|
||||
)
|
||||
id = Column(Integer, primary_key=True, nullable=False)
|
||||
# NOTE(tr3buchet): the ____compute variables are instance['host']
|
||||
|
@ -765,6 +766,7 @@ class Migration(BASE, NovaBase, models.SoftDeleteMixin):
|
|||
old_instance_type_id = Column(Integer())
|
||||
new_instance_type_id = Column(Integer())
|
||||
instance_uuid = Column(String(36), ForeignKey('instances.uuid'))
|
||||
uuid = Column(String(36), nullable=True)
|
||||
# TODO(_cerberus_): enum
|
||||
status = Column(String(255))
|
||||
migration_type = Column(Enum('migration', 'resize', 'live-migration',
|
||||
|
|
|
@ -965,6 +965,9 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
def _check_362(self, engine, data):
|
||||
self.assertColumnExists(engine, 'pci_devices', 'uuid')
|
||||
|
||||
def _check_373(self, engine, data):
|
||||
self.assertColumnExists(engine, 'migrations', 'uuid')
|
||||
|
||||
|
||||
class TestNovaMigrationsSQLite(NovaMigrationsCheckers,
|
||||
test_base.DbTestCase,
|
||||
|
|
Loading…
Reference in New Issue