diff options
| author | Brian Waldon <bcwaldon@gmail.com> | 2012-01-25 15:20:38 -0800 |
|---|---|---|
| committer | Brian Waldon <bcwaldon@gmail.com> | 2012-01-25 15:43:00 -0800 |
| commit | b4523032029604df34e045d6f6777a695328cff4 (patch) | |
| tree | 0c597d17704a5de284749e66087073a34abfca34 | |
| parent | e6c8051a23b6ed570656d7a209472a7d6489978f (diff) | |
Ignore connection_type when no instances exist
In migration 74, we had required that the connection_type flag
be set. That's annoying for new deployments, so bypass this check
if there are no instances in the databse. Fixes bug 921294
Change-Id: I9b829e80ad7fa7ded3c7a471cb68c9b342d973bb
| -rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py b/nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py index ef7e3293a..61fa86494 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py @@ -70,13 +70,22 @@ def upgrade_other(instances, instance_types): ephemeral_gb=0).execute() -def upgrade(migrate_engine): - if not FLAGS.connection_type: - raise exception.Error("Need connection_type specified to run " - "migration") +def check_instance_presence(migrate_engine, instances_table): + result = migrate_engine.execute(instances_table.select().limit(1)) + return result.fetchone() is not None + +def upgrade(migrate_engine): meta.bind = migrate_engine instances = _get_table('instances') + + data_present = check_instance_presence(migrate_engine, instances) + + if data_present and not FLAGS.connection_type: + msg = ("Found instance records in database. You must specify " + "connection_type to run migration migration") + raise exception.Error(msg) + instance_types = _get_table('instance_types') for table in (instances, instance_types): |
