summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-05-02 14:48:25 -0400
committerDan Prince <dprince@redhat.com>2012-05-02 21:58:09 -0400
commitee2f6f1bed21a5ef92d84634cd4e949062073d62 (patch)
treebffd019880ea439b6aef60a3c4f8283b9ded5df3
parente175c5f1c0275ed43648d43e6e46129680fc6d1b (diff)
downloadnova-ee2f6f1bed21a5ef92d84634cd4e949062073d62.tar.gz
nova-ee2f6f1bed21a5ef92d84634cd4e949062073d62.tar.xz
nova-ee2f6f1bed21a5ef92d84634cd4e949062073d62.zip
Compact pre-Folsom database migrations.
Compacts the pre-Folsom database migrations into a single migration (082_essex.py). Pre-Folsom users will need to upgrade to Essex before running any Folsom migrations. Implements blueprint db-migration-cleanup. Testing notes available at: http://wiki.openstack.org/database_migration_testing Change-Id: I64c06a3adcf83d6d723c4c11001544ba97668413
-rw-r--r--nova/db/migration.py2
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/001_austin.py627
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/002_bexar.py236
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/002_postgresql_downgrade.sql20
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/002_sqlite_downgrade.sql388
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/003_add_label_to_networks.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/003_sqlite_downgrade.sql111
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/004_add_zone_tables.py66
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/005_add_instance_metadata.py81
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py54
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/006_sqlite_downgrade.sql113
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py70
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql79
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/008_add_instance_types.py85
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/009_add_instance_migrations.py70
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/010_add_os_type_to_instances.py45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/011_live_migration.py85
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/012_add_ipv6_flatmanager.py90
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/012_sqlite_upgrade.sql195
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/013_add_flavors_to_migrations.py43
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql69
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/014_add_instance_type_id_to_instances.py74
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/015_add_auto_assign_to_floating_ips.py35
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/015_sqlite_downgrade.sql62
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py213
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/017_make_instance_type_id_an_integer.py87
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py35
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/019_add_volume_snapshot_support.py82
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/020_add_snapshot_id_to_volumes.py40
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/020_sqlite_downgrade.sql119
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py38
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/022_set_engine_mysql_innodb.py64
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/024_add_block_device_mapping.py92
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/025_add_uuid_to_instances.py45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/026_add_agent_table.py89
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/027_add_provider_firewall_rules.py65
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/028_add_instance_type_extra_specs.py76
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/029_add_zone_weight_offsets.py41
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/030_multi_nic.py146
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/030_sqlite_downgrade.sql377
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/031_fk_fixed_ips_virtual_interface_id.py59
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_downgrade.sql48
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_upgrade.sql48
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/032_add_root_device_name.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/033_ha_network.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/033_sqlite_downgrade.sql193
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/034_change_instance_id_in_migrations.py46
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/035_secondary_dns.py39
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/036_change_flavor_id_in_migrations.py79
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/037_instances_drop_admin_pass.py42
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/038_add_uuid_to_virtual_interfaces.py45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/038_sqlite_downgrade.sql63
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/039_add_instances_accessip.py49
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/040_add_uuid_to_networks.py45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py36
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/042_add_volume_types_and_extradata.py122
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/042_sqlite_downgrade.sql129
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/043_add_vsa_data.py84
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/044_update_instance_states.py132
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/045_add_network_priority.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/046_add_instance_swap.py49
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/047_remove_instances_fk_from_vif.py61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_downgrade.sql46
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_upgrade.sql45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/048_add_zone_name.py33
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/049_add_instances_progress.py44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/050_add_disk_config_to_instances.py37
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/050_sqlite_downgrade.sql207
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py34
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py65
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py38
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/053_sqlite_downgrade.sql87
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/054_add_bw_usage_data_cache.py64
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/055_convert_flavor_id_to_str.py112
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/056_add_s3_images.py60
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/057_add_sm_driver_tables.py113
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/058_rename_managed_disk.py37
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/059_split_rxtx_quota_into_network.py61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_downgrade.sql137
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_upgrade.sql87
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/060_remove_network_fk_from_vif.py62
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_downgrade.sql45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_upgrade.sql44
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/061_add_index_to_instance_uuid.py29
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/062_add_instance_info_cache_table.py70
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/063_add_instance_faults_table.py60
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py80
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/065_add_index_to_instance_project_id.py31
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/066_preload_instance_info_cache_table.py244
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/067_add_pool_and_interface_to_floating_ip.py45
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/067_sqlite_downgrade.sql69
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/068_add_instance_attribute.py36
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/068_sqlite_downgrade.sql219
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/069_block_migration.py50
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_downgrade.sql103
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_upgrade.sql99
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/070_untie_nova_network_models.py100
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/071_add_host_aggregate_tables.py108
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/072_add_dns_table.py77
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/072_mysql_upgrade.sql13
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/073_add_capacity.py49
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py130
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/074_sqlite_upgrade.sql313
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/075_convert_bw_usage_to_store_network_id.py97
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/076_remove_unique_constraints.py84
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/076_sqlite_upgrade.sql61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/077_convert_to_utf8.py61
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/078_add_rpc_info_to_zones.py46
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/078_sqlite_downgrade.sql35
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/079_add_zone_name_to_instances.py30
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/080_add_hypervisor_hostname_to_compute_nodes.py30
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/081_drop_instance_id_bw_cache.py69
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/082_essex.py981
-rw-r--r--nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py35
-rw-r--r--nova/db/sqlalchemy/migration.py29
-rw-r--r--nova/tests/__init__.py5
-rw-r--r--nova/tests/test_migrations.py15
118 files changed, 1006 insertions, 9845 deletions
diff --git a/nova/db/migration.py b/nova/db/migration.py
index 722d7ee48..76b70e14d 100644
--- a/nova/db/migration.py
+++ b/nova/db/migration.py
@@ -24,6 +24,8 @@ from nova import utils
IMPL = utils.LazyPluggable('db_backend',
sqlalchemy='nova.db.sqlalchemy.migration')
+INIT_VERSION = 81
+
def db_sync(version=None):
"""Migrate the database to `version` or the most recent version."""
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/001_austin.py b/nova/db/sqlalchemy/migrate_repo/versions/001_austin.py
deleted file mode 100644
index 9107cde91..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/001_austin.py
+++ /dev/null
@@ -1,627 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# 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.
-
-## Table code mostly autogenerated by genmodel.py
-from sqlalchemy import Boolean, Column, DateTime, ForeignKey
-from sqlalchemy import ForeignKeyConstraint, Integer, MetaData, String
-from sqlalchemy import Table, Text
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- auth_tokens = Table('auth_tokens', 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('token_hash',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- Column('user_id', Integer()),
- Column('server_manageent_url',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('storage_url',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('cdn_management_url',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- export_devices = Table('export_devices', 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('shelf_id', Integer()),
- Column('blade_id', Integer()),
- Column('volume_id',
- Integer(),
- ForeignKey('volumes.id'),
- nullable=True),
- )
-
- fixed_ips = Table('fixed_ips', 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('address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('network_id',
- Integer(),
- ForeignKey('networks.id'),
- nullable=True),
- Column('instance_id',
- Integer(),
- ForeignKey('instances.id'),
- nullable=True),
- Column('allocated', Boolean(create_constraint=True, name=None)),
- Column('leased', Boolean(create_constraint=True, name=None)),
- Column('reserved', Boolean(create_constraint=True, name=None)),
- )
-
- floating_ips = Table('floating_ips', 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('address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('fixed_ip_id',
- Integer(),
- ForeignKey('fixed_ips.id'),
- nullable=True),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- instances = Table('instances', 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('internal_id', Integer()),
- Column('admin_pass',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('image_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('kernel_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('ramdisk_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('server_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('launch_index', Integer()),
- Column('key_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('key_data',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('state', Integer()),
- Column('state_description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('memory_mb', Integer()),
- Column('vcpus', Integer()),
- Column('local_gb', Integer()),
- Column('hostname',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('instance_type',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('user_data',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('reservation_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('mac_address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('scheduled_at', DateTime(timezone=False)),
- Column('launched_at', DateTime(timezone=False)),
- Column('terminated_at', DateTime(timezone=False)),
- Column('display_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('display_description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- key_pairs = Table('key_pairs', 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('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('fingerprint',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('public_key',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- networks = Table('networks', 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('injected', Boolean(create_constraint=True, name=None)),
- Column('cidr',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('netmask',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('bridge',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('gateway',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('broadcast',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('dns',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('vlan', Integer()),
- Column('vpn_public_address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('vpn_public_port', Integer()),
- Column('vpn_private_address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('dhcp_start',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- projects = Table('projects', 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(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- Column('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_manager',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- ForeignKey('users.id')),
- )
-
- quotas = Table('quotas', 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('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('instances', Integer()),
- Column('cores', Integer()),
- Column('volumes', Integer()),
- Column('gigabytes', Integer()),
- Column('floating_ips', Integer()),
- )
-
- security_groups = Table('security_groups', 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('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- security_group_inst_assoc = Table('security_group_instance_association',
- 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('security_group_id',
- Integer(),
- ForeignKey('security_groups.id')),
- Column('instance_id', Integer(), ForeignKey('instances.id')),
- )
-
- security_group_rules = Table('security_group_rules', 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('parent_group_id',
- Integer(),
- ForeignKey('security_groups.id')),
- Column('protocol',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('from_port', Integer()),
- Column('to_port', Integer()),
- Column('cidr',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('group_id',
- Integer(),
- ForeignKey('security_groups.id')),
- )
-
- services = Table('services', 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('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('binary',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('topic',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('report_count', Integer(), nullable=False),
- Column('disabled', Boolean(create_constraint=True, name=None)),
- )
-
- users = Table('users', 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(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- Column('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('access_key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('secret_key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('is_admin', Boolean(create_constraint=True, name=None)),
- )
-
- user_project_association = Table('user_project_association', 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('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- ForeignKey('users.id'),
- primary_key=True,
- nullable=False),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- ForeignKey('projects.id'),
- primary_key=True,
- nullable=False),
- )
-
- user_project_role_association = Table('user_project_role_association',
- 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('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- Column('role',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- ForeignKeyConstraint(['user_id',
- 'project_id'],
- ['user_project_association.user_id',
- 'user_project_association.project_id']),
- )
-
- user_role_association = Table('user_role_association', 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('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- ForeignKey('users.id'),
- primary_key=True,
- nullable=False),
- Column('role',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True,
- nullable=False),
- )
-
- volumes = Table('volumes', 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('ec2_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('size', Integer()),
- Column('availability_zone',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('instance_id',
- Integer(),
- ForeignKey('instances.id'),
- nullable=True),
- Column('mountpoint',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('attach_time',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('status',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('attach_status',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('scheduled_at', DateTime(timezone=False)),
- Column('launched_at', DateTime(timezone=False)),
- Column('terminated_at', DateTime(timezone=False)),
- Column('display_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('display_description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
- tables = [auth_tokens,
- instances, key_pairs, networks, fixed_ips, floating_ips,
- quotas, security_groups, security_group_inst_assoc,
- security_group_rules, services, users, projects,
- user_project_association, user_project_role_association,
- user_role_association, volumes, export_devices]
-
- for table in tables:
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=tables)
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- auth_tokens = Table('auth_tokens', meta, autoload=True)
- export_devices = Table('export_devices', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- floating_ips = Table('floating_ips', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- key_pairs = Table('key_pairs', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- projects = Table('projects', meta, autoload=True)
- quotas = Table('quotas', meta, autoload=True)
- security_groups = Table('security_groups', meta, autoload=True)
- security_group_inst_assoc = Table('security_group_instance_association',
- meta, autoload=True)
- security_group_rules = Table('security_group_rules', meta, autoload=True)
- services = Table('services', meta, autoload=True)
- users = Table('users', meta, autoload=True)
- user_project_association = Table('user_project_association', meta,
- autoload=True)
- user_project_role_association = Table('user_project_role_association',
- meta,
- autoload=True)
- user_role_association = Table('user_role_association', meta, autoload=True)
- volumes = Table('volumes', meta, autoload=True)
-
- # table order matters, don't change
- for table in (auth_tokens, export_devices, floating_ips, fixed_ips,
- key_pairs, networks,
- quotas, security_group_inst_assoc,
- security_group_rules, security_groups, services,
- user_project_role_association, user_project_association,
- user_role_association,
- projects, users, volumes, instances):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/002_bexar.py b/nova/db/sqlalchemy/migrate_repo/versions/002_bexar.py
deleted file mode 100644
index 7fcc7da5b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/002_bexar.py
+++ /dev/null
@@ -1,236 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# 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, ForeignKey
-from sqlalchemy import Integer, MetaData, String, Table, Text
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- instances = Table('instances', meta, autoload=True)
- services = Table('services', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- auth_tokens = Table('auth_tokens', meta, autoload=True)
-
- #
- # New Tables
- #
- certificates = Table('certificates', 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('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('file_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- consoles = Table('consoles', 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('instance_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('instance_id', Integer()),
- Column('password',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('port', Integer(), nullable=True),
- Column('pool_id',
- Integer(),
- ForeignKey('console_pools.id')),
- )
-
- console_pools = Table('console_pools', 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('address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('username',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('password',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('console_type',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('public_hostname',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('compute_host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- instance_actions = Table('instance_actions', 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('instance_id',
- Integer(),
- ForeignKey('instances.id')),
- Column('action',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('error',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- iscsi_targets = Table('iscsi_targets', 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('target_num', Integer()),
- Column('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('volume_id',
- Integer(),
- ForeignKey('volumes.id'),
- nullable=True),
- )
-
- tables = [certificates, console_pools, consoles, instance_actions,
- iscsi_targets]
- for table in tables:
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=tables)
- raise
-
- auth_tokens.c.user_id.alter(type=String(length=255,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- #
- # New Columns
- #
- instances_availability_zone = Column(
- 'availability_zone',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
-
- instances_locked = Column('locked',
- Boolean(create_constraint=True, name=None))
-
- networks_cidr_v6 = Column(
- 'cidr_v6',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
-
- networks_ra_server = Column(
- 'ra_server',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
-
- services_availability_zone = Column(
- 'availability_zone',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
-
- instances.create_column(instances_availability_zone)
- instances.create_column(instances_locked)
- networks.create_column(networks_cidr_v6)
- networks.create_column(networks_ra_server)
- services.create_column(services_availability_zone)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- instances = Table('instances', meta, autoload=True)
- services = Table('services', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- auth_tokens = Table('auth_tokens', meta, autoload=True)
-
- certificates = Table('certificates', meta, autoload=True)
- consoles = Table('consoles', meta, autoload=True)
- console_pools = Table('console_pools', meta, autoload=True)
- instance_actions = Table('instance_actions', meta, autoload=True)
- iscsi_targets = Table('iscsi_targets', meta, autoload=True)
-
- # table order matters, don't change
- tables = [certificates, consoles, console_pools, instance_actions,
- iscsi_targets]
- for table in tables:
- table.drop()
-
- auth_tokens.c.user_id.alter(type=Integer())
-
- instances.drop_column('availability_zone')
- instances.drop_column('locked')
- networks.drop_column('cidr_v6')
- networks.drop_column('ra_server')
- services.drop_column('availability_zone')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/002_postgresql_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/002_postgresql_downgrade.sql
deleted file mode 100644
index cf5c1a208..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/002_postgresql_downgrade.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-BEGIN;
-
- DROP TABLE certificates;
- DROP TABLE consoles;
- DROP TABLE console_pools;
- DROP TABLE instance_actions;
- DROP TABLE iscsi_targets;
-
- ALTER TABLE auth_tokens ADD COLUMN user_id_backup INTEGER;
- UPDATE auth_tokens SET user_id_backup = CAST(user_id AS INTEGER);
- ALTER TABLE auth_tokens DROP COLUMN user_id;
- ALTER TABLE auth_tokens RENAME COLUMN user_id_backup TO user_id;
-
- ALTER TABLE instances DROP COLUMN availability_zone;
- ALTER TABLE instances DROP COLUMN locked;
- ALTER TABLE networks DROP COLUMN cidr_v6;
- ALTER TABLE networks DROP COLUMN ra_server;
- ALTER TABLE services DROP COLUMN availability_zone;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/002_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/002_sqlite_downgrade.sql
deleted file mode 100644
index 8c6a5beca..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/002_sqlite_downgrade.sql
+++ /dev/null
@@ -1,388 +0,0 @@
-BEGIN TRANSACTION;
-
- DROP TABLE certificates;
-
- DROP TABLE console_pools;
-
- DROP TABLE consoles;
-
- DROP TABLE instance_actions;
-
- DROP TABLE iscsi_targets;
-
- CREATE TEMPORARY TABLE auth_tokens_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- token_hash VARCHAR(255) NOT NULL,
- user_id VARCHAR(255),
- server_manageent_url VARCHAR(255),
- storage_url VARCHAR(255),
- cdn_management_url VARCHAR(255),
- PRIMARY KEY (token_hash),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO auth_tokens_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- token_hash,
- user_id,
- server_manageent_url,
- storage_url,
- cdn_management_url
- FROM auth_tokens;
-
- DROP TABLE auth_tokens;
-
- CREATE TABLE auth_tokens (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- token_hash VARCHAR(255) NOT NULL,
- user_id INTEGER,
- server_manageent_url VARCHAR(255),
- storage_url VARCHAR(255),
- cdn_management_url VARCHAR(255),
- PRIMARY KEY (token_hash),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO auth_tokens
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- token_hash,
- user_id,
- server_manageent_url,
- storage_url,
- cdn_management_url
- FROM auth_tokens_backup;
-
- DROP TABLE auth_tokens_backup;
-
- CREATE TEMPORARY TABLE instances_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- admin_pass VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_id VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- state INTEGER,
- state_description VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- instance_type VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- mac_address VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1))
- );
-
- INSERT INTO instances_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- admin_pass,
- user_id,
- project_id,
- image_id,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- state,
- state_description,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- instance_type,
- user_data,
- reservation_id,
- mac_address,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked
- FROM instances;
-
- DROP TABLE instances;
-
- CREATE TABLE instances (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- admin_pass VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_id VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- state INTEGER,
- state_description VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- instance_type VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- mac_address VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO instances
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- admin_pass,
- user_id,
- project_id,
- image_id,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- state,
- state_description,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- instance_type,
- user_data,
- reservation_id,
- mac_address,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description
- FROM instances_backup;
-
- DROP TABLE instances_backup;
-
- CREATE TEMPORARY TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- ra_server VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- ra_server
- FROM networks;
-
- DROP TABLE networks;
-
- CREATE TABLE networks (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1))
- );
-
- INSERT INTO networks
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host
- FROM networks_backup;
-
- DROP TABLE networks_backup;
-
- CREATE TEMPORARY TABLE services_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- host VARCHAR(255),
- binary VARCHAR(255),
- topic VARCHAR(255),
- report_count INTEGER NOT NULL,
- disabled BOOLEAN,
- availability_zone VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (disabled IN (0, 1))
- );
-
- INSERT INTO services_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- host,
- binary,
- topic,
- report_count,
- disabled,
- availability_zone
- FROM services;
-
- DROP TABLE services;
-
- CREATE TABLE services (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- host VARCHAR(255),
- binary VARCHAR(255),
- topic VARCHAR(255),
- report_count INTEGER NOT NULL,
- disabled BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (disabled IN (0, 1))
- );
-
- INSERT INTO services
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- host,
- binary,
- topic,
- report_count,
- disabled
- FROM services_backup;
-
- DROP TABLE services_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/003_add_label_to_networks.py b/nova/db/sqlalchemy/migrate_repo/versions/003_add_label_to_networks.py
deleted file mode 100644
index 668b77f0f..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/003_add_label_to_networks.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks_label = Column(
- 'label',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
- networks.create_column(networks_label)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks.drop_column('label')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/003_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/003_sqlite_downgrade.sql
deleted file mode 100644
index 01601cac0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/003_sqlite_downgrade.sql
+++ /dev/null
@@ -1,111 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- ra_server VARCHAR(255),
- label VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- ra_server,
- label
- FROM networks;
-
- DROP TABLE networks;
-
- CREATE TABLE networks (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- ra_server VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1))
- );
-
- INSERT INTO networks
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- ra_server
- FROM networks_backup;
-
- DROP TABLE networks_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/004_add_zone_tables.py b/nova/db/sqlalchemy/migrate_repo/versions/004_add_zone_tables.py
deleted file mode 100644
index 359e2c0bf..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/004_add_zone_tables.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2010 OpenStack LLC.
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- zones = Table('zones', 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('api_url',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('username',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('password',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- for table in (zones, ):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- for table in (zones, ):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/005_add_instance_metadata.py b/nova/db/sqlalchemy/migrate_repo/versions/005_add_instance_metadata.py
deleted file mode 100644
index 286bf9cb2..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/005_add_instance_metadata.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 Justin Santa Barbara
-# 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, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- quotas = Table('quotas', meta, autoload=True)
-
- instance_metadata_table = Table('instance_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('instance_id',
- Integer(),
- ForeignKey('instances.id'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('value',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
-
- for table in (instance_metadata_table, ):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- raise
-
- quota_metadata_items = Column('metadata_items', Integer())
- quotas.create_column(quota_metadata_items)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- quotas = Table('quotas', meta, autoload=True)
-
- instance_metadata_table = Table('instance_metadata', meta, autoload=True)
-
- for table in (instance_metadata_table, ):
- table.drop()
-
- quotas.drop_column('metadata_items')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py b/nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py
deleted file mode 100644
index df2be9df4..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/006_add_provider_data_to_volumes.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 Justin Santa Barbara.
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- # Add columns to existing tables
- volumes_provider_location = Column('provider_location',
- String(length=256,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- volumes_provider_auth = Column('provider_auth',
- String(length=256,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
- volumes.create_column(volumes_provider_location)
- volumes.create_column(volumes_provider_auth)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- volumes.drop_column('provider_location')
- volumes.drop_column('provider_auth')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/006_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/006_sqlite_downgrade.sql
deleted file mode 100644
index f55c28437..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/006_sqlite_downgrade.sql
+++ /dev/null
@@ -1,113 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE volumes_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(256),
- provider_auth VARCHAR(256),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO volumes_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth
- FROM volumes;
-
- DROP TABLE volumes;
-
- CREATE TABLE volumes (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO volumes
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description
- FROM volumes_backup;
-
- DROP TABLE volumes_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py b/nova/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py
deleted file mode 100644
index d84fa1734..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2011 OpenStack LLC
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- fixed_ips = Table('fixed_ips', meta, autoload=True)
-
- #
- # New Columns
- #
- fixed_ips_addressV6 = Column(
- "addressV6",
- String(
- length=255,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- fixed_ips_netmaskV6 = Column(
- "netmaskV6",
- String(
- length=3,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- fixed_ips_gatewayV6 = Column(
- "gatewayV6",
- String(
- length=255,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
- # Add columns to existing tables
- fixed_ips.create_column(fixed_ips_addressV6)
- fixed_ips.create_column(fixed_ips_netmaskV6)
- fixed_ips.create_column(fixed_ips_gatewayV6)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- fixed_ips = Table('fixed_ips', meta, autoload=True)
-
- fixed_ips.drop_column('addressV6')
- fixed_ips.drop_column('netmaskV6')
- fixed_ips.drop_column('gatewayV6')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql
deleted file mode 100644
index 44d347698..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/007_sqlite_downgrade.sql
+++ /dev/null
@@ -1,79 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN DEFAULT FALSE,
- leased BOOLEAN DEFAULT FALSE,
- reserved BOOLEAN DEFAULT FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- addressV6 VARCHAR(255),
- netmaskV6 VARCHAR(3),
- gatewayV6 VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (leased IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- CHECK (reserved IN (0, 1))
- );
-
- INSERT INTO fixed_ips_backup
- SELECT id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- created_at,
- updated_at,
- deleted_at,
- deleted,
- addressV6,
- netmaskV6,
- gatewayV6
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN DEFAULT FALSE,
- leased BOOLEAN DEFAULT FALSE,
- reserved BOOLEAN DEFAULT FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id),
- CHECK (leased IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- CHECK (reserved IN (0, 1))
- );
-
- INSERT INTO fixed_ips
- SELECT id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- created_at,
- updated_at,
- deleted_at,
- deleted
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/008_add_instance_types.py b/nova/db/sqlalchemy/migrate_repo/versions/008_add_instance_types.py
deleted file mode 100644
index b9ffee239..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/008_add_instance_types.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 Ken Pepple
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here
- # Don't create your own engine; bind migrate_engine
- # to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- #
- # New Tables
- #
- instance_types = Table('instance_types', 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('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- unique=True),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('memory_mb', Integer(), nullable=False),
- Column('vcpus', Integer(), nullable=False),
- Column('local_gb', Integer(), nullable=False),
- Column('flavorid', Integer(), nullable=False, unique=True),
- Column('swap', Integer(), nullable=False, default=0),
- Column('rxtx_quota', Integer(), nullable=False, default=0),
- Column('rxtx_cap', Integer(), nullable=False, default=0))
- try:
- instance_types.create()
- except Exception:
- LOG.info(repr(instance_types))
- LOG.exception('Exception while creating instance_types table')
- raise
-
- # Here are the old static instance types
- INSTANCE_TYPES = {
- 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
- 'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
- 'm1.medium': dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3),
- 'm1.large': dict(memory_mb=8192, vcpus=4, local_gb=80, flavorid=4),
- 'm1.xlarge': dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)}
- try:
- i = instance_types.insert()
- for name, values in INSTANCE_TYPES.iteritems():
- # FIXME(kpepple) should we be seeding created_at / updated_at ?
- # now = datetime.datatime.utcnow()
- i.execute({'name': name, 'memory_mb': values["memory_mb"],
- 'vcpus': values["vcpus"], 'deleted': False,
- 'local_gb': values["local_gb"],
- 'flavorid': values["flavorid"]})
- except Exception:
- LOG.info(repr(instance_types))
- LOG.exception('Exception while seeding instance_types table')
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- instance_types = Table('instance_types', meta, autoload=True)
- for table in (instance_types, ):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/009_add_instance_migrations.py b/nova/db/sqlalchemy/migrate_repo/versions/009_add_instance_migrations.py
deleted file mode 100644
index a0ae130d1..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/009_add_instance_migrations.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-# 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, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- #
- # New Tables
- #
- migrations = Table('migrations', 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('source_compute', String(255)),
- Column('dest_compute', String(255)),
- Column('dest_host', String(255)),
- Column('instance_id', Integer, ForeignKey('instances.id'),
- nullable=True),
- Column('status', String(255)),
- )
-
- for table in (migrations, ):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- migrations = Table('migrations', meta, autoload=True)
-
- for table in (migrations, ):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/010_add_os_type_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/010_add_os_type_to_instances.py
deleted file mode 100644
index da01940bd..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/010_add_os_type_to_instances.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-#
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances_os_type = Column('os_type',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(instances_os_type)
- migrate_engine.execute(instances.update()\
- .where(instances.c.os_type == None)\
- .values(os_type='linux'))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('os_type')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/011_live_migration.py b/nova/db/sqlalchemy/migrate_repo/versions/011_live_migration.py
deleted file mode 100644
index 8f3df2d6e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/011_live_migration.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# 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, Integer, MetaData
-from sqlalchemy import Table, Text
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- compute_nodes = Table('compute_nodes', 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('service_id', Integer(), nullable=False),
-
- Column('vcpus', Integer(), nullable=False),
- Column('memory_mb', Integer(), nullable=False),
- Column('local_gb', Integer(), nullable=False),
- Column('vcpus_used', Integer(), nullable=False),
- Column('memory_mb_used', Integer(), nullable=False),
- Column('local_gb_used', Integer(), nullable=False),
- Column('hypervisor_type',
- Text(convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- Column('hypervisor_version', Integer(), nullable=False),
- Column('cpu_info',
- Text(convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- )
-
- try:
- compute_nodes.create()
- except Exception:
- LOG.info(repr(compute_nodes))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=[compute_nodes])
- raise
-
- instances_launched_on = Column(
- 'launched_on',
- Text(convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(instances_launched_on)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- compute_nodes = Table('compute_nodes', meta, autoload=True)
-
- compute_nodes.drop()
-
- instances.drop_column('launched_on')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/012_add_ipv6_flatmanager.py b/nova/db/sqlalchemy/migrate_repo/versions/012_add_ipv6_flatmanager.py
deleted file mode 100644
index a626d2c7d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/012_add_ipv6_flatmanager.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (c) 2011 NTT.
-# 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, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- networks = Table('networks', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
-
- # Alter column name
- networks.c.ra_server.alter(name='gateway_v6')
- # Add new column to existing table
- networks_netmask_v6 = Column(
- 'netmask_v6',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
- networks.create_column(networks_netmask_v6)
-
- # drop existing columns from table
- fixed_ips.c.addressV6.drop()
- fixed_ips.c.netmaskV6.drop()
- fixed_ips.c.gatewayV6.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- networks = Table('networks', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
-
- networks.c.gateway_v6.alter(name='ra_server')
- networks.drop_column('netmask_v6')
-
- fixed_ips_addressV6 = Column(
- "addressV6",
- String(
- length=255,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- fixed_ips_netmaskV6 = Column(
- "netmaskV6",
- String(
- length=3,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- fixed_ips_gatewayV6 = Column(
- "gatewayV6",
- String(
- length=255,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False))
-
- for column in (fixed_ips_addressV6,
- fixed_ips_netmaskV6,
- fixed_ips_gatewayV6):
- fixed_ips.create_column(column)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/012_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/012_sqlite_upgrade.sql
deleted file mode 100644
index 0779f50e8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/012_sqlite_upgrade.sql
+++ /dev/null
@@ -1,195 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- ra_server VARCHAR(255),
- label VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (injected IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- ra_server,
- label
- FROM networks;
-
- DROP TABLE networks;
-
- CREATE TABLE networks (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (injected IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO networks
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- ra_server AS gateway_v6,
- label,
- NULL AS netmask_v6
- FROM networks_backup;
-
- DROP TABLE networks_backup;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- addressV6 VARCHAR(255),
- netmaskV6 VARCHAR(3),
- gatewayV6 VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (reserved IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (leased IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- FOREIGN KEY(network_id) REFERENCES networks (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- addressV6,
- netmaskV6,
- gatewayV6
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- PRIMARY KEY (id),
- CHECK (reserved IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (leased IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- FOREIGN KEY(network_id) REFERENCES networks (id)
- );
-
- INSERT INTO fixed_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/013_add_flavors_to_migrations.py b/nova/db/sqlalchemy/migrate_repo/versions/013_add_flavors_to_migrations.py
deleted file mode 100644
index d8735ec7d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/013_add_flavors_to_migrations.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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, Integer, MetaData, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- migrations = Table('migrations', meta, autoload=True)
-
- old_flavor_id = Column('old_flavor_id', Integer())
- new_flavor_id = Column('new_flavor_id', Integer())
-
- migrations.create_column(old_flavor_id)
- migrations.create_column(new_flavor_id)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- migrations = Table('migrations', meta, autoload=True)
-
- migrations.drop_column('old_flavor_id')
- migrations.drop_column('new_flavor_id')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql
deleted file mode 100644
index fbba364be..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/013_sqlite_downgrade.sql
+++ /dev/null
@@ -1,69 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE migrations_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- source_compute VARCHAR(255),
- dest_compute VARCHAR(255),
- dest_host VARCHAR(255),
- instance_id INTEGER,
- status VARCHAR(255),
- old_flavor_id INTEGER,
- new_flavor_id INTEGER,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO migrations_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- source_compute,
- dest_compute,
- dest_host,
- instance_id,
- status,
- old_flavor_id,
- new_flavor_id
- FROM migrations;
-
- DROP TABLE migrations;
-
- CREATE TABLE migrations (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- source_compute VARCHAR(255),
- dest_compute VARCHAR(255),
- dest_host VARCHAR(255),
- instance_id INTEGER,
- status VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO migrations
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- source_compute,
- dest_compute,
- dest_host,
- instance_id,
- status
- FROM migrations_backup;
-
- DROP TABLE migrations_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/014_add_instance_type_id_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/014_add_instance_type_id_to_instances.py
deleted file mode 100644
index b363caca5..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/014_add_instance_type_id_to_instances.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-#
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
-
- c_instance_type_id = Column('instance_type_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
-
- instances.create_column(c_instance_type_id)
-
- type_names = {}
- recs = migrate_engine.execute(instance_types.select())
- for row in recs:
- type_names[row[0]] = row[1]
-
- for type_id, type_name in type_names.iteritems():
- migrate_engine.execute(instances.update()\
- .where(instances.c.instance_type == type_name)\
- .values(instance_type_id=type_id))
-
- instances.c.instance_type.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
-
- c_instance_type = Column('instance_type',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(c_instance_type)
-
- type_names = {}
- recs = migrate_engine.execute(instance_types.select())
- for row in recs:
- type_names[row[0]] = row[1]
-
- for type_id, type_name in type_names.iteritems():
- migrate_engine.execute(instances.update()\
- .where(instances.c.instance_type_id == type_id)\
- .values(instance_type=type_name))
-
- instances.c.instance_type_id.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/015_add_auto_assign_to_floating_ips.py b/nova/db/sqlalchemy/migrate_repo/versions/015_add_auto_assign_to_floating_ips.py
deleted file mode 100644
index 51db85066..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/015_add_auto_assign_to_floating_ips.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# Copyright 2011 Grid Dynamics
-#
-# 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):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- floating_ips = Table('floating_ips', meta, autoload=True)
- c_auto_assigned = Column('auto_assigned', Boolean, default=False)
- floating_ips.create_column(c_auto_assigned)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- floating_ips = Table('floating_ips', meta, autoload=True)
- floating_ips.drop_column('auto_assigned')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/015_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/015_sqlite_downgrade.sql
deleted file mode 100644
index c599ef2b3..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/015_sqlite_downgrade.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE floating_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (auto_assigned IN (0, 1)),
- FOREIGN KEY(fixed_ip_id) REFERENCES fixed_ips (id)
- );
-
- INSERT INTO floating_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- fixed_ip_id,
- project_id,
- host,
- auto_assigned
- FROM floating_ips;
-
- DROP TABLE floating_ips;
-
- CREATE TABLE floating_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(fixed_ip_id) REFERENCES fixed_ips (id)
- );
-
- INSERT INTO floating_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- fixed_ip_id,
- project_id,
- host
- FROM floating_ips_backup;
-
- DROP TABLE floating_ips_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py b/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py
deleted file mode 100644
index 2d3134e65..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-
-from nova import utils
-
-resources = [
- 'instances',
- 'cores',
- 'volumes',
- 'gigabytes',
- 'floating_ips',
- 'metadata_items',
-]
-
-
-def old_style_quotas_table(meta, name):
- return Table(name, meta,
- Column('id', Integer(), primary_key=True),
- Column('created_at', DateTime(),
- default=utils.utcnow),
- Column('updated_at', DateTime(),
- onupdate=utils.utcnow),
- Column('deleted_at', DateTime()),
- Column('deleted', Boolean(), default=False),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('instances', Integer()),
- Column('cores', Integer()),
- Column('volumes', Integer()),
- Column('gigabytes', Integer()),
- Column('floating_ips', Integer()),
- Column('metadata_items', Integer()),
- )
-
-
-def new_style_quotas_table(meta, name):
- return Table(name, meta,
- Column('id', Integer(), primary_key=True),
- Column('created_at', DateTime(),
- default=utils.utcnow),
- Column('updated_at', DateTime(),
- onupdate=utils.utcnow),
- Column('deleted_at', DateTime()),
- Column('deleted', Boolean(), default=False),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False)),
- Column('resource',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=False),
- Column('hard_limit', Integer(), nullable=True),
- )
-
-
-def quotas_table(meta, name='quotas'):
- return Table(name, meta, autoload=True)
-
-
-def _assert_no_duplicate_project_ids(quotas):
- project_ids = set()
- message = ('There are multiple active quotas for project "%s" '
- '(among others, possibly). '
- 'Please resolve all ambiguous quotas before '
- 'reattempting the migration.')
- for quota in quotas:
- assert quota.project_id not in project_ids, message % quota.project_id
- project_ids.add(quota.project_id)
-
-
-def assert_old_quotas_have_no_active_duplicates(migrate_engine, quotas):
- """Ensure that there are no duplicate non-deleted quota entries."""
- select = quotas.select().where(quotas.c.deleted == False)
- results = migrate_engine.execute(select)
- _assert_no_duplicate_project_ids(list(results))
-
-
-def assert_new_quotas_have_no_active_duplicates(migrate_engine, quotas):
- """Ensure that there are no duplicate non-deleted quota entries."""
- for resource in resources:
- select = quotas.select().\
- where(quotas.c.deleted == False).\
- where(quotas.c.resource == resource)
- results = migrate_engine.execute(select)
- _assert_no_duplicate_project_ids(list(results))
-
-
-def convert_forward(migrate_engine, old_quotas, new_quotas):
- quotas = list(migrate_engine.execute(old_quotas.select()))
- for quota in quotas:
- for resource in resources:
- hard_limit = getattr(quota, resource)
- if hard_limit is None:
- continue
- insert = new_quotas.insert().values(
- created_at=quota.created_at,
- updated_at=quota.updated_at,
- deleted_at=quota.deleted_at,
- deleted=quota.deleted,
- project_id=quota.project_id,
- resource=resource,
- hard_limit=hard_limit)
- migrate_engine.execute(insert)
-
-
-def earliest(date1, date2):
- if date1 is None and date2 is None:
- return None
- if date1 is None:
- return date2
- if date2 is None:
- return date1
- if date1 < date2:
- return date1
- return date2
-
-
-def latest(date1, date2):
- if date1 is None and date2 is None:
- return None
- if date1 is None:
- return date2
- if date2 is None:
- return date1
- if date1 > date2:
- return date1
- return date2
-
-
-def convert_backward(migrate_engine, old_quotas, new_quotas):
- quotas = {}
- for quota in migrate_engine.execute(new_quotas.select()):
- if (quota.resource not in resources
- or quota.hard_limit is None or quota.deleted):
- continue
- if not quota.project_id in quotas:
- quotas[quota.project_id] = {
- 'project_id': quota.project_id,
- 'created_at': quota.created_at,
- 'updated_at': quota.updated_at,
- quota.resource: quota.hard_limit,
- }
- else:
- quotas[quota.project_id]['created_at'] = earliest(
- quota.created_at, quotas[quota.project_id]['created_at'])
- quotas[quota.project_id]['updated_at'] = latest(
- quota.updated_at, quotas[quota.project_id]['updated_at'])
- quotas[quota.project_id][quota.resource] = quota.hard_limit
-
- for quota in quotas.itervalues():
- insert = old_quotas.insert().values(**quota)
- migrate_engine.execute(insert)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- old_quotas = quotas_table(meta)
- assert_old_quotas_have_no_active_duplicates(migrate_engine, old_quotas)
-
- new_quotas = new_style_quotas_table(meta, 'quotas_new')
- new_quotas.create()
- convert_forward(migrate_engine, old_quotas, new_quotas)
- old_quotas.drop()
-
- # clear metadata to work around this:
- # http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=128
- meta.clear()
- new_quotas = quotas_table(meta, 'quotas_new')
- new_quotas.rename('quotas')
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- new_quotas = quotas_table(meta)
- assert_new_quotas_have_no_active_duplicates(migrate_engine, new_quotas)
-
- old_quotas = old_style_quotas_table(meta, 'quotas_old')
- old_quotas.create()
- convert_backward(migrate_engine, old_quotas, new_quotas)
- new_quotas.drop()
-
- # clear metadata to work around this:
- # http://code.google.com/p/sqlalchemy-migrate/issues/detail?id=128
- meta.clear()
- old_quotas = quotas_table(meta, 'quotas_old')
- old_quotas.rename('quotas')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/017_make_instance_type_id_an_integer.py b/nova/db/sqlalchemy/migrate_repo/versions/017_make_instance_type_id_an_integer.py
deleted file mode 100644
index 90757396c..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/017_make_instance_type_id_an_integer.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# 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, Integer, MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- types = {}
- for instance in migrate_engine.execute(instances.select()):
- if instance.instance_type_id is None:
- types[instance.id] = None
- continue
- try:
- types[instance.id] = int(instance.instance_type_id)
- except ValueError:
- LOG.warn("Instance %s did not have instance_type_id "
- "converted to an integer because its value is %s" %
- (instance.id, instance.instance_type_id))
- types[instance.id] = None
-
- integer_column = Column('instance_type_id_int', Integer(), nullable=True)
- string_column = instances.c.instance_type_id
-
- integer_column.create(instances)
- for instance_id, instance_type_id in types.iteritems():
- update = instances.update().\
- where(instances.c.id == instance_id).\
- values(instance_type_id_int=instance_type_id)
- migrate_engine.execute(update)
-
- string_column.alter(name='instance_type_id_str')
- integer_column.alter(name='instance_type_id')
- string_column.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- integer_column = instances.c.instance_type_id
- string_column = Column('instance_type_id_str',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
-
- types = {}
- for instance in migrate_engine.execute(instances.select()):
- if instance.instance_type_id is None:
- types[instance.id] = None
- else:
- types[instance.id] = str(instance.instance_type_id)
-
- string_column.create(instances)
- for instance_id, instance_type_id in types.iteritems():
- update = instances.update().\
- where(instances.c.id == instance_id).\
- values(instance_type_id_str=instance_type_id)
- migrate_engine.execute(update)
-
- integer_column.alter(name='instance_type_id_int')
- string_column.alter(name='instance_type_id')
- integer_column.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py b/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py
deleted file mode 100644
index 59ead97ad..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/018_rename_server_management_url.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-#
-# 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):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- tokens = Table('auth_tokens', meta, autoload=True)
- c_manageent = tokens.c.server_manageent_url
- c_manageent.alter(name='server_management_url')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- tokens = Table('auth_tokens', meta, autoload=True)
- c_management = tokens.c.server_management_url
- c_management.alter(name='server_manageent_url')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/019_add_volume_snapshot_support.py b/nova/db/sqlalchemy/migrate_repo/versions/019_add_volume_snapshot_support.py
deleted file mode 100644
index b459f3832..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/019_add_volume_snapshot_support.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 MORITA Kazutaka.
-# 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, Table, MetaData
-from sqlalchemy import Integer, DateTime, Boolean, String
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- snapshots = Table('snapshots', 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', Integer(), nullable=False),
- Column('user_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('status',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('progress',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('volume_size', Integer()),
- Column('scheduled_at', DateTime(timezone=False)),
- Column('display_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('display_description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
- try:
- snapshots.create()
- except Exception:
- LOG.info(repr(snapshots))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=[snapshots])
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- snapshots = Table('snapshots', meta, autoload=True)
- snapshots.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_add_snapshot_id_to_volumes.py b/nova/db/sqlalchemy/migrate_repo/versions/020_add_snapshot_id_to_volumes.py
deleted file mode 100644
index c5a632ca0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/020_add_snapshot_id_to_volumes.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 MORITA Kazutaka.
-# 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, Table, MetaData, Integer
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- snapshot_id = Column('snapshot_id', Integer())
- # Add columns to existing tables
- volumes.create_column(snapshot_id)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- volumes.drop_column('snapshot_id')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/020_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/020_sqlite_downgrade.sql
deleted file mode 100644
index 97b946604..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/020_sqlite_downgrade.sql
+++ /dev/null
@@ -1,119 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE volumes_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(256),
- provider_auth VARCHAR(256),
- snapshot_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- snapshot_id
- FROM volumes;
-
- DROP TABLE volumes;
-
- CREATE TABLE volumes (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(256),
- provider_auth VARCHAR(256),
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth
- FROM volumes_backup;
-
- DROP TABLE volumes_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py b/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py
deleted file mode 100644
index 64b539ed6..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/021_rename_image_ids.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- image_id_column = instances.c.image_id
- image_id_column.alter(name='image_ref')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- image_ref_column = instances.c.image_ref
- image_ref_column.alter(name='image_id')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/022_set_engine_mysql_innodb.py b/nova/db/sqlalchemy/migrate_repo/versions/022_set_engine_mysql_innodb.py
deleted file mode 100644
index 2c10b790a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/022_set_engine_mysql_innodb.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- if migrate_engine.name == "mysql":
- migrate_engine.execute("ALTER TABLE auth_tokens Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE certificates Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE compute_nodes Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE console_pools Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE consoles Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE export_devices Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE fixed_ips Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE floating_ips Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE instance_actions Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE instance_metadata Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE instance_types Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE instances Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE iscsi_targets Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE key_pairs Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE migrate_version Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE migrations Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE networks Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE projects Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE quotas Engine=InnoDB")
- migrate_engine.execute(
- "ALTER TABLE security_group_instance_association Engine=InnoDB")
- migrate_engine.execute(
- "ALTER TABLE security_group_rules Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE security_groups Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE services Engine=InnoDB")
- migrate_engine.execute(
- "ALTER TABLE user_project_association Engine=InnoDB")
- migrate_engine.execute(
- "ALTER TABLE user_project_role_association Engine=InnoDB")
- migrate_engine.execute(
- "ALTER TABLE user_role_association Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE users Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE volumes Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE zones Engine=InnoDB")
- migrate_engine.execute("ALTER TABLE snapshots Engine=InnoDB")
-
-
-def downgrade(migrate_engine):
- pass
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py
deleted file mode 100644
index ee607dd92..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/023_add_vm_mode_to_instances.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances_vm_mode = Column('vm_mode',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(instances_vm_mode)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('vm_mode')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/024_add_block_device_mapping.py b/nova/db/sqlalchemy/migrate_repo/versions/024_add_block_device_mapping.py
deleted file mode 100644
index 202ea634e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/024_add_block_device_mapping.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# Copyright 2011 Isaku Yamahata
-#
-# 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, Column
-from sqlalchemy import DateTime, Boolean, Integer, String
-from sqlalchemy import ForeignKey
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
-
- #
- # New Tables
- #
- block_device_mapping = Table('block_device_mapping', 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, autoincrement=True),
- Column('instance_id',
- Integer(),
- ForeignKey('instances.id'),
- nullable=False),
- Column('device_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- Column('delete_on_termination',
- Boolean(create_constraint=True, name=None),
- default=False),
- Column('virtual_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True),
- Column('snapshot_id',
- Integer(),
- ForeignKey('snapshots.id'),
- nullable=True),
- Column('volume_id', Integer(), ForeignKey('volumes.id'),
- nullable=True),
- Column('volume_size', Integer(), nullable=True),
- Column('no_device',
- Boolean(create_constraint=True, name=None),
- nullable=True),
- )
- try:
- block_device_mapping.create()
- except Exception:
- LOG.info(repr(block_device_mapping))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=[block_device_mapping])
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
- volumes = Table('volumes', meta, autoload=True)
- snapshots = Table('snapshots', meta, autoload=True)
-
- block_device_mapping = Table('block_device_mapping', meta, autoload=True)
- block_device_mapping.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/025_add_uuid_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/025_add_uuid_to_instances.py
deleted file mode 100644
index 3aaa6d79e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/025_add_uuid_to_instances.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, String, Table
-
-from nova import utils
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- uuid_column = Column("uuid", String(36))
- instances.create_column(uuid_column)
-
- rows = migrate_engine.execute(instances.select())
- for row in rows:
- instance_uuid = str(utils.gen_uuid())
- migrate_engine.execute(instances.update()\
- .where(instances.c.id == row[0])\
- .values(uuid=instance_uuid))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('uuid')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/026_add_agent_table.py b/nova/db/sqlalchemy/migrate_repo/versions/026_add_agent_table.py
deleted file mode 100644
index 4665c75ae..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/026_add_agent_table.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- #
- # New Tables
- #
- builds = Table('agent_builds', 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('hypervisor',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('os',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('architecture',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('version',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('url',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('md5hash',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
- for table in (builds, ):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
-
- instances = Table('instances', meta, autoload=True)
-
- #
- # New Columns
- #
- architecture = Column('architecture', String(length=255))
-
- # Add columns to existing tables
- instances.create_column(architecture)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- builds = Table('agent_builds', meta, autoload=True)
- for table in (builds, ):
- table.drop()
-
- instances = Table('instances', meta, autoload=True)
- instances.drop_column('architecture')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/027_add_provider_firewall_rules.py b/nova/db/sqlalchemy/migrate_repo/versions/027_add_provider_firewall_rules.py
deleted file mode 100644
index ed82ede9d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/027_add_provider_firewall_rules.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# 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 Integer, MetaData, String
-from sqlalchemy import Table
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- #
- # New Tables
- #
- provider_fw_rules = Table('provider_fw_rules', 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('protocol',
- String(length=5, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('from_port', Integer()),
- Column('to_port', Integer()),
- Column('cidr',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
- for table in (provider_fw_rules,):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- provider_fw_rules = Table('provider_fw_rules', meta, autoload=True)
- for table in (provider_fw_rules,):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/028_add_instance_type_extra_specs.py b/nova/db/sqlalchemy/migrate_repo/versions/028_add_instance_type_extra_specs.py
deleted file mode 100644
index 29c3ab13c..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/028_add_instance_type_extra_specs.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 University of Southern California
-#
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instance_types = Table('instance_types', meta, autoload=True)
-
- #
- # New Tables
- #
- instance_type_extra_specs_table = Table('instance_type_extra_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', Integer(), primary_key=True, nullable=False),
- Column('instance_type_id',
- Integer(),
- ForeignKey('instance_types.id'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('value',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
-
- for table in (instance_type_extra_specs_table, ):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instance_types = Table('instance_types', meta, autoload=True)
-
- instance_type_extra_specs_table = Table('instance_type_extra_specs',
- meta,
- autoload=True)
- for table in (instance_type_extra_specs_table, ):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/029_add_zone_weight_offsets.py b/nova/db/sqlalchemy/migrate_repo/versions/029_add_zone_weight_offsets.py
deleted file mode 100644
index 80eb836c0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/029_add_zone_weight_offsets.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Float, Integer, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- #
- # New Columns
- #
- weight_offset = Column('weight_offset', Float(), default=0.0)
- weight_scale = Column('weight_scale', Float(), default=1.0)
-
- zones.create_column(weight_offset)
- zones.create_column(weight_scale)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- zones.drop_column('weight_offset')
- zones.drop_column('weight_scale')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/030_multi_nic.py b/nova/db/sqlalchemy/migrate_repo/versions/030_multi_nic.py
deleted file mode 100644
index db58ef76e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/030_multi_nic.py
+++ /dev/null
@@ -1,146 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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 select, Boolean, Column, DateTime, ForeignKey
-from sqlalchemy import Integer, MetaData, String
-from sqlalchemy import Table
-
-from nova import log as logging
-from nova import utils
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # grab tables and (column for dropping later)
- instances = Table('instances', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- c = instances.columns['mac_address']
-
- interface = Column('bridge_interface',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False))
-
- virtual_interface_id = Column('virtual_interface_id',
- Integer())
- # add interface column to networks table
- # values will have to be set manually before running nova
- try:
- networks.create_column(interface)
- except Exception:
- LOG.error(_("interface column not added to networks table"))
- raise
-
- #
- # New Tables
- #
- virtual_interfaces = Table('virtual_interfaces', meta,
- Column('created_at', DateTime(timezone=False),
- default=utils.utcnow()),
- Column('updated_at', DateTime(timezone=False),
- onupdate=utils.utcnow()),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- unique=True),
- Column('network_id',
- Integer(),
- ForeignKey('networks.id')),
- Column('instance_id',
- Integer(),
- ForeignKey('instances.id'),
- nullable=False),
- mysql_engine='InnoDB')
-
- # create virtual_interfaces table
- try:
- virtual_interfaces.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(virtual_interfaces))
- raise
-
- # add virtual_interface_id column to fixed_ips table
- try:
- fixed_ips.create_column(virtual_interface_id)
- except Exception:
- LOG.error(_("VIF column not added to fixed_ips table"))
- raise
-
- # populate the virtual_interfaces table
- # extract data from existing instance and fixed_ip tables
- s = select([instances.c.id, instances.c.mac_address,
- fixed_ips.c.network_id],
- fixed_ips.c.instance_id == instances.c.id)
- keys = ('instance_id', 'address', 'network_id')
- join_list = [dict(zip(keys, row)) for row in s.execute()]
- LOG.debug(_("join list for moving mac_addresses |%s|"), join_list)
-
- # insert data into the table
- if join_list:
- i = virtual_interfaces.insert()
- i.execute(join_list)
-
- # populate the fixed_ips virtual_interface_id column
- s = select([fixed_ips.c.id, fixed_ips.c.instance_id],
- fixed_ips.c.instance_id != None)
-
- for row in s.execute():
- m = select([virtual_interfaces.c.id]).\
- where(virtual_interfaces.c.instance_id == row['instance_id']).\
- as_scalar()
- u = fixed_ips.update().values(virtual_interface_id=m).\
- where(fixed_ips.c.id == row['id'])
- u.execute()
-
- # drop the mac_address column from instances
- c.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # grab tables and (column for dropping later)
- instances = Table('instances', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
-
- mac_address = Column('mac_address',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False))
-
- instances.create_column(mac_address)
-
- s = select([instances.c.id, virtual_interfaces.c.address],
- virtual_interfaces.c.instance_id == instances.c.id)
-
- for row in s.execute():
- u = instances.update().values(mac_address=row['address']).\
- where(instances.c.id == row['id'])
-
- networks.drop_column('bridge_interface')
- virtual_interfaces.drop()
- fixed_ips.drop_column('virtual_interface_id')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/030_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/030_sqlite_downgrade.sql
deleted file mode 100644
index 2486e6d2d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/030_sqlite_downgrade.sql
+++ /dev/null
@@ -1,377 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE instances_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- admin_pass VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- state INTEGER,
- state_description VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (locked IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO instances_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- admin_pass,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- state,
- state_description,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture
- FROM instances;
-
- DROP TABLE instances;
-
- CREATE TABLE instances (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- admin_pass VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- state INTEGER,
- state_description VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- mac_address VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (locked IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO instances
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- admin_pass,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- state,
- state_description,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- NULL AS mac_address
- FROM instances_backup;
-
- DROP TABLE instances_backup;
-
- UPDATE instances SET mac_address=(SELECT address
- FROM virtual_interfaces
- WHERE virtual_interfaces.instance_id = instances.id);
-
- CREATE TEMPORARY TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- bridge_interface VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (injected IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- gateway_v6,
- label,
- netmask_v6,
- bridge_interface
- FROM networks;
-
- DROP TABLE networks;
-
- CREATE TABLE networks (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (injected IN (0, 1)),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO networks
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- gateway_v6,
- label,
- netmask_v6
- FROM networks_backup;
-
- DROP TABLE networks_backup;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- virtual_interface_id INTEGER,
- PRIMARY KEY (id),
- CHECK (reserved IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (leased IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- FOREIGN KEY(network_id) REFERENCES networks (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- virtual_interface_id
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN,
- leased BOOLEAN,
- reserved BOOLEAN,
- PRIMARY KEY (id),
- CHECK (reserved IN (0, 1)),
- CHECK (allocated IN (0, 1)),
- CHECK (leased IN (0, 1)),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- FOREIGN KEY(network_id) REFERENCES networks (id)
- );
-
- INSERT INTO fixed_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/031_fk_fixed_ips_virtual_interface_id.py b/nova/db/sqlalchemy/migrate_repo/versions/031_fk_fixed_ips_virtual_interface_id.py
deleted file mode 100644
index 962903f9f..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/031_fk_fixed_ips_virtual_interface_id.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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 MetaData, Table
-from migrate import ForeignKeyConstraint
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
-
- # grab tables
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
-
- # add foreignkey if not sqlite
- try:
- if not dialect.startswith('sqlite'):
- ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
- refcolumns=[virtual_interfaces.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be added"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
-
- # grab tables
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
-
- # drop foreignkey if not sqlite
- try:
- if not dialect.startswith('sqlite'):
- ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
- refcolumns=[virtual_interfaces.c.id]).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_downgrade.sql
deleted file mode 100644
index c1d26b180..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_downgrade.sql
+++ /dev/null
@@ -1,48 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(virtual_interface_id) REFERENCES virtual_interfaces (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT id, address, virtual_interface_id, network_id, instance_id, allocated, leased, reserved, created_at, updated_at, deleted_at, deleted
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips
- SELECT id, address, virtual_interface_id, network_id, instance_id, allocated, leased, reserved, created_at, updated_at, deleted_at, deleted
- FROM fixed_ips;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_upgrade.sql
deleted file mode 100644
index 2a9362545..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/031_sqlite_upgrade.sql
+++ /dev/null
@@ -1,48 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT id, address, virtual_interface_id, network_id, instance_id, allocated, leased, reserved, created_at, updated_at, deleted_at, deleted
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(virtual_interface_id) REFERENCES virtual_interfaces (id)
- );
-
- INSERT INTO fixed_ips
- SELECT id, address, virtual_interface_id, network_id, instance_id, allocated, leased, reserved, created_at, updated_at, deleted_at, deleted
- FROM fixed_ips;
-
- DROP TABLE fixed_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/032_add_root_device_name.py b/nova/db/sqlalchemy/migrate_repo/versions/032_add_root_device_name.py
deleted file mode 100644
index f12070c57..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/032_add_root_device_name.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# Copyright 2011 Isaku Yamahata
-#
-# 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, Integer, MetaData, Table, String
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- root_device_name = Column(
- 'root_device_name',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(root_device_name)
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('root_device_name')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/033_ha_network.py b/nova/db/sqlalchemy/migrate_repo/versions/033_ha_network.py
deleted file mode 100644
index becc353f6..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/033_ha_network.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 OpenStack, LLC.
-# 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, Table, MetaData, Boolean, String
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- fixed_ips_host = Column('host', String(255))
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- fixed_ips.create_column(fixed_ips_host)
-
- networks_multi_host = Column('multi_host', Boolean, default=False)
- networks = Table('networks', meta, autoload=True)
- networks.create_column(networks_multi_host)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- fixed_ips.drop_column('host')
-
- networks = Table('networks', meta, autoload=True)
- networks.drop_column('multi_host')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/033_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/033_sqlite_downgrade.sql
deleted file mode 100644
index 34188d866..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/033_sqlite_downgrade.sql
+++ /dev/null
@@ -1,193 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE fixed_ips_backup (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- host VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(virtual_interface_id) REFERENCES virtual_interfaces (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT id,
- address,
- virtual_interface_id,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- created_at,
- updated_at,
- deleted_at,
- deleted,
- host
- FROM fixed_ips;
-
- DROP TABLE fixed_ips;
-
- CREATE TABLE fixed_ips (
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(virtual_interface_id) REFERENCES virtual_interfaces (id)
- );
-
- INSERT INTO fixed_ips
- SELECT id,
- address,
- virtual_interface_id,
- network_id,
- instance_id,
- allocated,
- leased,
- reserved,
- created_at,
- updated_at,
- deleted_at,
- deleted
- FROM fixed_ips_backup;
-
- DROP TABLE fixed_ips_backup;
-
- CREATE TEMPORARY TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- bridge_interface VARCHAR(255),
- multi_host BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1)),
- CHECK (multi_host IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- gateway_v6,
- label,
- netmask_v6,
- bridge_interface,
- multi_host
- FROM networks;
-
- DROP TABLE networks;
-
- CREATE TABLE networks(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- bridge_interface VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1))
- );
-
- INSERT INTO networks
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- gateway_v6,
- label,
- netmask_v6,
- bridge_interface
- FROM networks_backup;
-
- DROP TABLE networks_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/034_change_instance_id_in_migrations.py b/nova/db/sqlalchemy/migrate_repo/versions/034_change_instance_id_in_migrations.py
deleted file mode 100644
index 9cf004301..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/034_change_instance_id_in_migrations.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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, Integer, String, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- migrations = Table('migrations', meta, autoload=True)
- instance_uuid = Column('instance_uuid', String(255))
- migrations.create_column(instance_uuid)
-
- if migrate_engine.name == "mysql":
- try:
- migrate_engine.execute("ALTER TABLE migrations DROP FOREIGN KEY "
- "`migrations_ibfk_1`;")
- except Exception: # Don't care, just fail silently.
- pass
-
- migrations.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- migrations = Table('migrations', meta, autoload=True)
- migrations.c.instance_uuid.drop()
- instance_id = Column('instance_id', Integer())
- migrations.create_column(instance_id)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/035_secondary_dns.py b/nova/db/sqlalchemy/migrate_repo/versions/035_secondary_dns.py
deleted file mode 100644
index c03e5be66..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/035_secondary_dns.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 OpenStack, LLC.
-# 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, Table, MetaData, String
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks.c.dns.alter(name='dns1')
- dns2 = Column('dns2', String(255))
- networks.create_column(dns2)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks.c.dns1.alter(name='dns')
- networks.drop_column('dns2')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/036_change_flavor_id_in_migrations.py b/nova/db/sqlalchemy/migrate_repo/versions/036_change_flavor_id_in_migrations.py
deleted file mode 100644
index 38f83fc01..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/036_change_flavor_id_in_migrations.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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, Integer, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- migrations = Table('migrations', meta, autoload=True)
-
- old_instance_type_id = Column('old_instance_type_id', Integer())
- new_instance_type_id = Column('new_instance_type_id', Integer())
- migrations.create_column(old_instance_type_id)
- migrations.create_column(new_instance_type_id)
-
- # Convert flavor_id to instance_type_id
- itypes = {}
- for instance_type in migrate_engine.execute(instance_types.select()):
- itypes[instance_type.id] = instance_type.flavorid
-
- for instance_type_id in itypes.keys():
- migrate_engine.execute(migrations.update()\
- .where(migrations.c.old_flavor_id == itypes[instance_type_id])\
- .values(old_instance_type_id=instance_type_id))
- migrate_engine.execute(migrations.update()\
- .where(migrations.c.new_flavor_id == itypes[instance_type_id])\
- .values(new_instance_type_id=instance_type_id))
-
- migrations.c.old_flavor_id.drop()
- migrations.c.new_flavor_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
- migrations = Table('migrations', meta, autoload=True)
-
- old_flavor_id = Column('old_flavor_id', Integer())
- new_flavor_id = Column('new_flavor_id', Integer())
-
- migrations.create_column(old_flavor_id)
- migrations.create_column(new_flavor_id)
-
- # Convert instance_type_id to flavor_id
- itypes = {}
- for instance_type in migrate_engine.execute(instance_types.select()):
- itypes[instance_type.flavorid] = instance_type.id
-
- for instance_type_flavorid in itypes.keys():
- migrate_engine.execute(migrations.update()\
- .where(migrations.c.old_instance_type_id ==
- itypes[instance_type_flavorid])\
- .values(old_flavor_id=instance_type_flavorid))
- migrate_engine.execute(migrations.update()\
- .where(migrations.c.new_instance_type_id ==
- itypes[instance_type_flavorid])\
- .values(new_flavor_id=instance_type_flavorid))
-
- migrations.c.old_instance_type_id.drop()
- migrations.c.new_instance_type_id.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/037_instances_drop_admin_pass.py b/nova/db/sqlalchemy/migrate_repo/versions/037_instances_drop_admin_pass.py
deleted file mode 100644
index c8a1a1927..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/037_instances_drop_admin_pass.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('admin_pass')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- #
- # New Columns
- #
- admin_pass = Column(
- 'admin_pass',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
-
- instances.create_column(admin_pass)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/038_add_uuid_to_virtual_interfaces.py b/nova/db/sqlalchemy/migrate_repo/versions/038_add_uuid_to_virtual_interfaces.py
deleted file mode 100644
index 64acaa030..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/038_add_uuid_to_virtual_interfaces.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (C) 2011 Midokura KK
-#
-# 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, Integer, MetaData, String, Table
-
-from nova import utils
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
-
- uuid_column = Column('uuid', String(36))
- virtual_interfaces.create_column(uuid_column)
-
- rows = migrate_engine.execute(virtual_interfaces.select())
- for row in rows:
- vif_uuid = str(utils.gen_uuid())
- migrate_engine.execute(virtual_interfaces.update()\
- .where(virtual_interfaces.c.id == row[0])\
- .values(uuid=vif_uuid))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
-
- virtual_interfaces.drop_column('uuid')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/038_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/038_sqlite_downgrade.sql
deleted file mode 100644
index 0ac66e7e0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/038_sqlite_downgrade.sql
+++ /dev/null
@@ -1,63 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id,
- uuid
- FROM virtual_interfaces;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- PRIMARY KEY (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- network_id,
- instance_id
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/039_add_instances_accessip.py b/nova/db/sqlalchemy/migrate_repo/versions/039_add_instances_accessip.py
deleted file mode 100644
index 8c8961cd3..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/039_add_instances_accessip.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, Table, String
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- accessIPv4 = Column(
- 'access_ip_v4',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
-
- accessIPv6 = Column(
- 'access_ip_v6',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(accessIPv4)
- instances.create_column(accessIPv6)
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('access_ip_v4')
- instances.drop_column('access_ip_v6')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/040_add_uuid_to_networks.py b/nova/db/sqlalchemy/migrate_repo/versions/040_add_uuid_to_networks.py
deleted file mode 100644
index 60191e1d4..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/040_add_uuid_to_networks.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, String, Table
-
-from nova import utils
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- uuid_column = Column("uuid", String(36))
- networks.create_column(uuid_column)
-
- rows = migrate_engine.execute(networks.select())
- for row in rows:
- networks_uuid = str(utils.gen_uuid())
- migrate_engine.execute(networks.update()\
- .where(networks.c.id == row[0])\
- .values(uuid=networks_uuid))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks.drop_column('uuid')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py
deleted file mode 100644
index f85c4a0d7..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/041_add_config_drive_to_instances.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2011 Piston Cloud Computing, Inc.
-#
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table("instances", meta, autoload=True)
-
- config_drive_column = Column("config_drive", String(255), nullable=True)
- instances.create_column(config_drive_column)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table("instances", meta, autoload=True)
-
- instances.drop_column('config_drive')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/042_add_volume_types_and_extradata.py b/nova/db/sqlalchemy/migrate_repo/versions/042_add_volume_types_and_extradata.py
deleted file mode 100644
index 98ff83748..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/042_add_volume_types_and_extradata.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 Zadara Storage Inc.
-# Copyright (c) 2011 OpenStack LLC.
-#
-# 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, MetaData, String, Table
-from sqlalchemy import Boolean, ForeignKey
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- #
- # New Tables
- #
- volume_types = Table('volume_types', 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('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- unique=True))
-
- volume_type_extra_specs_table = Table('volume_type_extra_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', Integer(), primary_key=True, nullable=False),
- Column('volume_type_id',
- Integer(),
- ForeignKey('volume_types.id'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('value',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
-
- volume_metadata_table = Table('volume_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',
- Integer(),
- ForeignKey('volumes.id'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('value',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)))
-
- new_tables = (volume_types,
- volume_type_extra_specs_table,
- volume_metadata_table)
-
- for table in new_tables:
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
- LOG.exception('Exception while creating table')
- raise
-
- #
- # New Columns
- #
- volume_type_id = Column('volume_type_id', Integer(), nullable=True)
- volumes.create_column(volume_type_id)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- volumes = Table('volumes', meta, autoload=True)
-
- volumes.drop_column('volume_type_id')
-
- volume_types = Table('volume_types', meta, autoload=True)
- volume_type_extra_specs_table = Table('volume_type_extra_specs',
- meta,
- autoload=True)
- volume_metadata_table = Table('volume_metadata', meta, autoload=True)
-
- # table order matters, don't change
- for table in (volume_type_extra_specs_table,
- volume_types,
- volume_metadata_table):
- table.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/042_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/042_sqlite_downgrade.sql
deleted file mode 100644
index 8fa39663a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/042_sqlite_downgrade.sql
+++ /dev/null
@@ -1,129 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE volumes_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(256),
- provider_auth VARCHAR(256),
- snapshot_id INTEGER,
- volume_type_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- snapshot_id,
- volume_type_id
- FROM volumes;
-
- DROP TABLE volumes;
-
- CREATE TABLE volumes (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- ec2_id VARCHAR(255),
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- size INTEGER,
- availability_zone VARCHAR(255),
- instance_id INTEGER,
- mountpoint VARCHAR(255),
- attach_time VARCHAR(255),
- status VARCHAR(255),
- attach_status VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- provider_location VARCHAR(256),
- provider_auth VARCHAR(256),
- snapshot_id INTEGER,
- PRIMARY KEY (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO volumes
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- ec2_id,
- user_id,
- project_id,
- host,
- size,
- availability_zone,
- instance_id,
- mountpoint,
- attach_time,
- status,
- attach_status,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- provider_location,
- provider_auth,
- snapshot_id
- FROM volumes_backup;
-
- DROP TABLE volumes_backup;
-
- DROP TABLE volume_type_extra_specs;
-
- DROP TABLE volume_types;
-
- DROP TABLE volume_metadata;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/043_add_vsa_data.py b/nova/db/sqlalchemy/migrate_repo/versions/043_add_vsa_data.py
deleted file mode 100644
index 441e41c39..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/043_add_vsa_data.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 Zadara Storage Inc.
-# Copyright (c) 2011 OpenStack LLC.
-#
-# 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, MetaData, String, Table
-from sqlalchemy import Boolean
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- virtual_storage_arrays = Table('virtual_storage_arrays', 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('display_name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('display_description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('availability_zone',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('instance_type_id', Integer(), nullable=False),
- Column('image_ref',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('vc_count', Integer(), nullable=False),
- Column('vol_count', Integer(), nullable=False),
- Column('status',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- try:
- virtual_storage_arrays.create()
- except Exception:
- LOG.info(repr(virtual_storage_arrays))
- LOG.exception('Exception while creating table')
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- virtual_storage_arrays = Table('virtual_storage_arrays',
- meta,
- autoload=True)
- virtual_storage_arrays.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/044_update_instance_states.py b/nova/db/sqlalchemy/migrate_repo/versions/044_update_instance_states.py
deleted file mode 100644
index 81da7b16d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/044_update_instance_states.py
+++ /dev/null
@@ -1,132 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-#
-# 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, Column, String
-
-from nova.compute import task_states
-from nova.compute import vm_states
-
-
-_upgrade_translations = {
- "stopping": {
- "state_description": vm_states.ACTIVE,
- "task_state": task_states.STOPPING,
- },
- "stopped": {
- "state_description": vm_states.STOPPED,
- "task_state": None,
- },
- "terminated": {
- "state_description": vm_states.DELETED,
- "task_state": None,
- },
- "terminating": {
- "state_description": vm_states.ACTIVE,
- "task_state": task_states.DELETING,
- },
- "running": {
- "state_description": vm_states.ACTIVE,
- "task_state": None,
- },
- "scheduling": {
- "state_description": vm_states.BUILDING,
- "task_state": task_states.SCHEDULING,
- },
- "migrating": {
- "state_description": vm_states.MIGRATING,
- "task_state": None,
- },
- "pending": {
- "state_description": vm_states.BUILDING,
- "task_state": task_states.SCHEDULING,
- },
-}
-
-
-_downgrade_translations = {
- vm_states.ACTIVE: {
- None: "running",
- task_states.DELETING: "terminating",
- task_states.STOPPING: "stopping",
- },
- vm_states.BUILDING: {
- None: "pending",
- task_states.SCHEDULING: "scheduling",
- },
- vm_states.STOPPED: {
- None: "stopped",
- },
- vm_states.REBUILDING: {
- None: "pending",
- },
- vm_states.DELETED: {
- None: "terminated",
- },
- vm_states.MIGRATING: {
- None: "migrating",
- },
-}
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_table = Table('instances', meta, autoload=True)
-
- c_state = instance_table.c.state
- c_state.alter(name='power_state')
-
- c_vm_state = instance_table.c.state_description
- c_vm_state.alter(name='vm_state')
-
- c_task_state = Column('task_state',
- String(length=255, convert_unicode=False,
- assert_unicode=None, unicode_error=None,
- _warn_on_bytestring=False),
- nullable=True)
- instance_table.create_column(c_task_state)
-
- for old_state, values in _upgrade_translations.iteritems():
- instance_table.update().\
- values(**values).\
- where(c_vm_state == old_state).\
- execute()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_table = Table('instances', meta, autoload=True)
-
- c_task_state = instance_table.c.task_state
-
- c_state = instance_table.c.power_state
- c_state.alter(name='state')
-
- c_vm_state = instance_table.c.vm_state
- c_vm_state.alter(name='state_description')
-
- for old_vm_state, old_task_states in _downgrade_translations.iteritems():
- for old_task_state, new_state_desc in old_task_states.iteritems():
- instance_table.update().\
- where(c_task_state == old_task_state).\
- where(c_vm_state == old_vm_state).\
- values(vm_state=new_state_desc).\
- execute()
-
- instance_table.drop_column('task_state')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/045_add_network_priority.py b/nova/db/sqlalchemy/migrate_repo/versions/045_add_network_priority.py
deleted file mode 100644
index 5d4e1e625..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/045_add_network_priority.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2011 Nicira, Inc.
-# 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, Integer, MetaData, Table
-
-from nova import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- priority = Column('priority', Integer())
- try:
- networks.create_column(priority)
- except Exception:
- LOG.error(_("priority column not added to networks table"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- networks = Table('networks', meta, autoload=True)
-
- networks.drop_column('priority')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/046_add_instance_swap.py b/nova/db/sqlalchemy/migrate_repo/versions/046_add_instance_swap.py
deleted file mode 100644
index 3ee1c4e7e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/046_add_instance_swap.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2011 Isaku Yamahata
-#
-# 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, Integer, MetaData, Table, String
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- default_local_device = Column(
- 'default_local_device',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
-
- default_swap_device = Column(
- 'default_swap_device',
- String(length=255, convert_unicode=False, assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=True)
- instances.create_column(default_local_device)
- instances.create_column(default_swap_device)
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('default_swap_device')
- instances.drop_column('default_local_device')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/047_remove_instances_fk_from_vif.py b/nova/db/sqlalchemy/migrate_repo/versions/047_remove_instances_fk_from_vif.py
deleted file mode 100644
index a750f956b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/047_remove_instances_fk_from_vif.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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 import ForeignKeyConstraint
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- instances = Table('instances', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
-
- try:
- fkey_name = list(vifs.c.instance_id.foreign_keys)[0].constraint.name
- ForeignKeyConstraint(columns=[vifs.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- instances = Table('instances', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
-
- try:
- ForeignKeyConstraint(columns=[vifs.c.instance_id],
- refcolumns=[instances.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be added"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_downgrade.sql
deleted file mode 100644
index 9bc3ee8d4..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_downgrade.sql
+++ /dev/null
@@ -1,46 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_upgrade.sql
deleted file mode 100644
index 2c0919f1d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/047_sqlite_upgrade.sql
+++ /dev/null
@@ -1,45 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/048_add_zone_name.py b/nova/db/sqlalchemy/migrate_repo/versions/048_add_zone_name.py
deleted file mode 100644
index e313fc7de..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/048_add_zone_name.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, String, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
- name = Column('name', String(255))
- zones.create_column(name)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- zones.drop_column('name')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/049_add_instances_progress.py b/nova/db/sqlalchemy/migrate_repo/versions/049_add_instances_progress.py
deleted file mode 100644
index f8d805e8b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/049_add_instances_progress.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 OpenStack LLC.
-#
-# 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, Integer, MetaData, Table
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- progress = Column('progress', Integer())
- try:
- instances.create_column(progress)
- except Exception:
- LOG.error(_("progress column not added to instances table"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('progress')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/050_add_disk_config_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/050_add_disk_config_to_instances.py
deleted file mode 100644
index d4a2fcc13..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/050_add_disk_config_to_instances.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- managed_disk = Column("managed_disk", Boolean(create_constraint=False,
- name=None))
- instances.create_column(managed_disk)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instances = Table('instances', meta, autoload=True)
-
- instances.drop_column('managed_disk')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/050_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/050_sqlite_downgrade.sql
deleted file mode 100644
index 8db7087bc..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/050_sqlite_downgrade.sql
+++ /dev/null
@@ -1,207 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE instances_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_local_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- managed_disk BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1)),
- CHECK (managed_disk IN (0, 1))
- );
-
- INSERT INTO instances_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress,
- managed_disk
- FROM instances;
-
- DROP TABLE instances;
-
- CREATE TABLE instances (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_local_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1))
- );
-
- INSERT INTO instances
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress
- FROM instances_backup;
-
- DROP TABLE instances_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py b/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py
deleted file mode 100644
index a33831993..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/051_add_vcpu_weight_to_instance_types.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
-
- vcpu_weight = Column("vcpu_weight", Integer())
- instance_types.create_column(vcpu_weight)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
-
- instance_types.drop_column('vcpu_weight')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py b/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py
deleted file mode 100644
index 4558dd9fa..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/052_kill_export_devices.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 University of Southern California
-#
-# 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, Integer
-from sqlalchemy import MetaData, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- #
- # New Tables
- #
- export_devices = Table('export_devices', 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('shelf_id', Integer()),
- Column('blade_id', Integer()),
- Column('volume_id',
- Integer(),
- ForeignKey('volumes.id'),
- nullable=True),
- )
-
- try:
- export_devices.create()
- except Exception:
- LOG.info(repr(export_devices))
- LOG.exception('Exception while creating table')
- raise
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- export_devices = Table('export_devices', meta, autoload=True)
-
- export_devices.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py b/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py
deleted file mode 100644
index 8fe139918..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/053_add_connection_info_to_block_device_mapping.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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, Table, Text
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- table = Table('block_device_mapping', meta, autoload=True)
-
- new_column = Column('connection_info', Text())
-
- table.create_column(new_column)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- table = Table('block_device_mapping', meta, autoload=True)
-
- table.c.connection_info.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/053_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/053_sqlite_downgrade.sql
deleted file mode 100644
index 844399763..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/053_sqlite_downgrade.sql
+++ /dev/null
@@ -1,87 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE block_device_mapping_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- connection_info TEXT,
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO block_device_mapping_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device,
- connection_info
- FROM block_device_mapping;
-
- DROP TABLE block_device_mapping;
-
- CREATE TABLE block_device_mapping (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- instance_id INTEGER NOT NULL,
- device_name VARCHAR(255) NOT NULL,
- delete_on_termination BOOLEAN,
- virtual_name VARCHAR(255),
- snapshot_id INTEGER,
- volume_id INTEGER,
- volume_size INTEGER,
- no_device BOOLEAN,
- PRIMARY KEY (id),
- FOREIGN KEY(snapshot_id) REFERENCES snapshots (id),
- CHECK (deleted IN (0, 1)),
- CHECK (delete_on_termination IN (0, 1)),
- CHECK (no_device IN (0, 1)),
- FOREIGN KEY(volume_id) REFERENCES volumes (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- INSERT INTO block_device_mapping
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- instance_id,
- device_name,
- delete_on_termination,
- virtual_name,
- snapshot_id,
- volume_id,
- volume_size,
- no_device
- FROM block_device_mapping_backup;
-
- DROP TABLE block_device_mapping_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/054_add_bw_usage_data_cache.py b/nova/db/sqlalchemy/migrate_repo/versions/054_add_bw_usage_data_cache.py
deleted file mode 100644
index cd585a81e..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/054_add_bw_usage_data_cache.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 MORITA Kazutaka.
-# 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, Table, MetaData
-from sqlalchemy import Integer, BigInteger, DateTime, Boolean, String
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- bw_cache = Table('bw_usage_cache', 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('instance_id', Integer(), nullable=False),
- Column('network_label',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('start_period', DateTime(timezone=False), nullable=False),
- Column('last_refreshed', DateTime(timezone=False)),
- Column('bw_in', BigInteger()),
- Column('bw_out', BigInteger()))
- try:
- bw_cache.create()
- except Exception:
- LOG.info(repr(bw_cache))
- LOG.exception('Exception while creating table')
- meta.drop_all(tables=[bw_cache])
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- bw_cache = Table('bw_usage_cache', meta, autoload=True)
- bw_cache.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/055_convert_flavor_id_to_str.py b/nova/db/sqlalchemy/migrate_repo/versions/055_convert_flavor_id_to_str.py
deleted file mode 100644
index 91c39edb0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/055_convert_flavor_id_to_str.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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 migrate
-import migrate.changeset
-from sqlalchemy import Column, Integer, String, MetaData, Table
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_types = Table('instance_types', meta, autoload=True)
-
- string_column = Column('flavorid_str', String(255))
-
- string_column.create(instance_types)
-
- try:
- # NOTE(bcwaldon): This catches a bug with python-migrate
- # failing to add the unique constraint
- try:
- migrate.UniqueConstraint(string_column).create()
- except migrate.changeset.NotSupportedError:
- LOG.error("Failed to add unique constraint on flavorid")
- pass
-
- # NOTE(bcwaldon): this is a hack to preserve uniqueness constraint
- # on existing 'name' column
- try:
- migrate.UniqueConstraint(instance_types.c.name).create()
- except Exception:
- pass
-
- integer_column = instance_types.c.flavorid
-
- instance_type_rows = list(instance_types.select().execute())
- for instance_type in instance_type_rows:
- flavorid_int = instance_type.flavorid
- instance_types.update()\
- .where(integer_column == flavorid_int)\
- .values(flavorid_str=str(flavorid_int))\
- .execute()
- except Exception:
- string_column.drop()
- raise
-
- integer_column.alter(name='flavorid_int')
- string_column.alter(name='flavorid')
- integer_column.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_types = Table('instance_types', meta, autoload=True)
-
- integer_column = Column('flavorid_int', Integer())
-
- integer_column.create(instance_types)
-
- try:
- # NOTE(bcwaldon): This catches a bug with python-migrate
- # failing to add the unique constraint
- try:
- migrate.UniqueConstraint(integer_column).create()
- except migrate.changeset.NotSupportedError:
- LOG.info("Failed to add unique constraint on flavorid")
- pass
-
- string_column = instance_types.c.flavorid
-
- instance_types_rows = list(instance_types.select().execute())
- for instance_type in instance_types_rows:
- flavorid_str = instance_type.flavorid
- try:
- flavorid_int = int(instance_type.flavorid)
- except ValueError:
- msg = _('Could not cast flavorid to integer: %s. '
- 'Set flavorid to an integer-like string to downgrade.')
- LOG.error(msg % instance_type.flavorid)
- raise
-
- instance_types.update()\
- .where(string_column == flavorid_str)\
- .values(flavorid_int=flavorid_int)\
- .execute()
- except Exception:
- integer_column.drop()
- raise
-
- string_column.alter(name='flavorid_str')
- integer_column.alter(name='flavorid')
- string_column.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/056_add_s3_images.py b/nova/db/sqlalchemy/migrate_repo/versions/056_add_s3_images.py
deleted file mode 100644
index 2c30c7986..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/056_add_s3_images.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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, Integer
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- #
- # New Tables
- #
- s3_images = Table('s3_images', 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,
- autoincrement=True),
- Column('uuid', String(36),
- nullable=False))
- try:
- s3_images.create()
- except Exception:
- LOG.exception("Exception while creating table 's3_images'")
- meta.drop_all(tables=[s3_images])
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- s3_images = Table('s3_images', meta, autoload=True)
- s3_images.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/057_add_sm_driver_tables.py b/nova/db/sqlalchemy/migrate_repo/versions/057_add_sm_driver_tables.py
deleted file mode 100644
index 7f1e4f297..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/057_add_sm_driver_tables.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright (c) 2011 Citrix Systems, Inc.
-#
-# 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
-from sqlalchemy import Table
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- #
- # New Tables
- #
- flavors = Table('sm_flavors', 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('label',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('description',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
-
- backend = Table('sm_backend_config', 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('flavor_id', Integer(), ForeignKey('sm_flavors.id'),
- nullable=False),
- Column('sr_uuid',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('sr_type',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('config_params',
- String(length=2047,
- convert_unicode=False,
- assert_unicode=None,
- unicode_error=None,
- _warn_on_bytestring=False)),
- )
-
- sm_vol = Table('sm_volume', 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(), 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, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
- for table in (flavors, backend, sm_vol):
- try:
- table.create()
- except Exception:
- LOG.info(repr(table))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- volumes = Table('volumes', meta, autoload=True)
-
- flavors = Table('sm_flavors', meta, autoload=True)
- backend = Table('sm_backend_config', meta, autoload=True)
- sm_vol = Table('sm_volume', meta, autoload=True)
-
- for table in (flavors, backend, sm_vol):
- try:
- table.drop()
- except Exception:
- LOG.info(repr(table))
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/058_rename_managed_disk.py b/nova/db/sqlalchemy/migrate_repo/versions/058_rename_managed_disk.py
deleted file mode 100644
index e12cabddd..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/058_rename_managed_disk.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-#
-# 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):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- managed_disk = instances.c.managed_disk
- managed_disk.alter(name='auto_disk_config')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- image_ref_column = instances.c.auto_disk_config
- image_ref_column.alter(name='managed_disk')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/059_split_rxtx_quota_into_network.py b/nova/db/sqlalchemy/migrate_repo/versions/059_split_rxtx_quota_into_network.py
deleted file mode 100644
index 58f6d69e0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/059_split_rxtx_quota_into_network.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, Float, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_types = Table('instance_types', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
-
- rxtx_base = Column('rxtx_base', Integer)
- rxtx_factor = Column('rxtx_factor', Float, default=1)
- instance_types.create_column(rxtx_factor)
- networks.create_column(rxtx_base)
-
- base = migrate_engine.execute("select min(rxtx_cap) as min_rxtx from "
- "instance_types where rxtx_cap > 0").scalar()
- base = base if base > 1 else 1
- update_i_type_sql = ("update instance_types set rxtx_factor = rxtx_cap"
- "/%s where rxtx_cap > 0" % base)
- migrate_engine.execute(update_i_type_sql)
- migrate_engine.execute("update networks set rxtx_base = %s" % base)
-
- instance_types.c.rxtx_quota.drop()
- instance_types.c.rxtx_cap.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_types = Table('instance_types', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
-
- rxtx_quota = Column('rxtx_quota', Integer)
- rxtx_cap = Column('rxtx_cap', Integer)
- instance_types.create_column(rxtx_quota)
- instance_types.create_column(rxtx_cap)
-
- base = migrate_engine.execute("select min(rxtx_base) from networks "
- "where rxtx_base > 0").scalar()
- base = base if base > 1 else 1
-
- update_i_type_sql = ("update instance_types set rxtx_cap = "
- "rxtx_factor * %s" % base)
- migrate_engine.execute(update_i_type_sql)
-
- instance_types.c.rxtx_factor.drop()
- networks.c.rxtx_base.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_downgrade.sql
deleted file mode 100644
index ecf45c599..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_downgrade.sql
+++ /dev/null
@@ -1,137 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE instance_types_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- local_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_quota INTEGER NOT NULL,
- rxtx_cap INTEGER NOT NULL,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- UNIQUE (flavorid),
- UNIQUE (name)
- );
-
- INSERT INTO instance_types_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- local_gb,
- swap,
- 0 as rxtx_quota,
- COALESCE(rxtx_factor, 1) * COALESCE ((SELECT MIN(rxtx_base)
- FROM networks
- WHERE rxtx_base > 0), 1)
- as rxtx_cap,
- vcpu_weight,
- flavorid FROM instance_types;
-
- DROP TABLE instance_types;
-
- CREATE TABLE instance_types (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- local_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_quota INTEGER NOT NULL,
- rxtx_cap INTEGER NOT NULL,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (flavorid),
- CHECK (deleted IN (0, 1)),
- UNIQUE (name)
- );
-
- INSERT INTO instance_types SELECT * FROM instance_types_backup;
- DROP TABLE instance_types_backup;
-
- CREATE TABLE networks_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- injected BOOLEAN,
- cidr VARCHAR(255),
- netmask VARCHAR(255),
- bridge VARCHAR(255),
- gateway VARCHAR(255),
- broadcast VARCHAR(255),
- dns1 VARCHAR(255),
- vlan INTEGER,
- vpn_public_address VARCHAR(255),
- vpn_public_port INTEGER,
- vpn_private_address VARCHAR(255),
- dhcp_start VARCHAR(255),
- project_id VARCHAR(255),
- host VARCHAR(255),
- cidr_v6 VARCHAR(255),
- gateway_v6 VARCHAR(255),
- label VARCHAR(255),
- netmask_v6 VARCHAR(255),
- bridge_interface VARCHAR(255),
- multi_host BOOLEAN,
- dns2 VARCHAR(255),
- uuid VARCHAR(36),
- priority INTEGER,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (injected IN (0, 1)),
- CHECK (multi_host IN (0, 1))
- );
-
- INSERT INTO networks_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- injected,
- cidr,
- netmask,
- bridge,
- gateway,
- broadcast,
- dns1,
- vlan,
- vpn_public_address,
- vpn_public_port,
- vpn_private_address,
- dhcp_start,
- project_id,
- host,
- cidr_v6,
- gateway_v6,
- label,
- netmask_v6,
- bridge_interface,
- multi_host,
- dns2,
- uuid,
- priority
- FROM networks;
-
- DROP TABLE networks;
- ALTER TABLE networks_backup RENAME TO networks;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_upgrade.sql
deleted file mode 100644
index ba7729aed..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/059_sqlite_upgrade.sql
+++ /dev/null
@@ -1,87 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE instance_types_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- local_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_factor FLOAT,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (flavorid),
- CHECK (deleted IN (0, 1)),
- UNIQUE (name)
- );
-
- INSERT INTO instance_types_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- local_gb,
- swap,
- COALESCE(rxtx_cap, 1) / COALESCE ((SELECT MIN(rxtx_cap)
- FROM instance_types
- WHERE rxtx_cap > 0), 1) as rxtx_cap,
- vcpu_weight,
- flavorid
- FROM instance_types;
-
- ALTER TABLE networks ADD COLUMN rxtx_base INTEGER DEFAULT 1;
-
- UPDATE networks SET rxtx_base = COALESCE((SELECT MIN(rxtx_cap)
- FROM instance_types
- WHERE rxtx_cap>0), 1);
-
- DROP TABLE instance_types;
-
- CREATE TABLE instance_types (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- local_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_factor FLOAT,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (flavorid),
- CHECK (deleted IN (0, 1)),
- UNIQUE (name)
- );
-
- INSERT INTO instance_types
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- local_gb,
- swap,
- rxtx_factor,
- vcpu_weight,
- flavorid
- FROM instance_types_backup;
-
- DROP TABLE instance_types_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/060_remove_network_fk_from_vif.py b/nova/db/sqlalchemy/migrate_repo/versions/060_remove_network_fk_from_vif.py
deleted file mode 100644
index 7515baa01..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/060_remove_network_fk_from_vif.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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 import ForeignKeyConstraint
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- networks = Table('networks', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
-
- try:
- fkey_name = list(vifs.c.network_id.foreign_keys)[0].constraint.name
- ForeignKeyConstraint(columns=[vifs.c.network_id],
- refcolumns=[networks.c.id],
- name=fkey_name).drop()
-
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- networks = Table('networks', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
-
- try:
- ForeignKeyConstraint(columns=[vifs.c.network_id],
- refcolumns=[networks.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be added"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_downgrade.sql
deleted file mode 100644
index 2c0919f1d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_downgrade.sql
+++ /dev/null
@@ -1,45 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_upgrade.sql
deleted file mode 100644
index fd49ea4f5..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/060_sqlite_upgrade.sql
+++ /dev/null
@@ -1,44 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TEMPORARY TABLE virtual_interfaces_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id)
- );
-
- INSERT INTO virtual_interfaces_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces;
-
- DROP TABLE virtual_interfaces;
-
- CREATE TABLE virtual_interfaces (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- network_id INTEGER,
- instance_id INTEGER NOT NULL,
- uuid VARCHAR(36),
- PRIMARY KEY (id),
- UNIQUE (address),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO virtual_interfaces
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- network_id, instance_id, uuid
- FROM virtual_interfaces_backup;
-
- DROP TABLE virtual_interfaces_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/061_add_index_to_instance_uuid.py b/nova/db/sqlalchemy/migrate_repo/versions/061_add_index_to_instance_uuid.py
deleted file mode 100644
index 1a369bffe..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/061_add_index_to_instance_uuid.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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 upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- Index('uuid', instances.c.uuid, unique=True).create(migrate_engine)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- Index('uuid', instances.c.uuid, unique=True).drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/062_add_instance_info_cache_table.py b/nova/db/sqlalchemy/migrate_repo/versions/062_add_instance_info_cache_table.py
deleted file mode 100644
index cbfd8ea5a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/062_add_instance_info_cache_table.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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, ForeignKey
-from sqlalchemy import Integer, MetaData, String
-from sqlalchemy import Table, Text
-
-from nova import log as logging
-from nova import utils
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- #
- # New Tables
- #
- instance_info_caches = Table('instance_info_caches', meta,
- Column('created_at', DateTime(timezone=False),
- default=utils.utcnow()),
- Column('updated_at', DateTime(timezone=False),
- onupdate=utils.utcnow()),
- Column('deleted_at', DateTime(timezone=False)),
- Column('deleted', Boolean(create_constraint=True, name=None)),
- Column('id', Integer(), primary_key=True),
- Column('network_info', Text()),
- Column('instance_id', String(36),
- ForeignKey('instances.uuid'),
- nullable=False,
- unique=True),
- mysql_engine='InnoDB')
- # create instance_info_caches table
- try:
- instance_info_caches.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(instance_info_caches))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- instances = Table('instances', meta, autoload=True)
-
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
- try:
- instance_info_caches.drop()
- except Exception:
- LOG.error(_("instance_info_caches tables not dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/063_add_instance_faults_table.py b/nova/db/sqlalchemy/migrate_repo/versions/063_add_instance_faults_table.py
deleted file mode 100644
index 03ec09971..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/063_add_instance_faults_table.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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, Integer, ForeignKey
-from sqlalchemy import MetaData, String, Table, Text
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- #
- # New Tables
- #
- instance_faults = Table('instance_faults', 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),
- default=False),
- Column('id', Integer(), primary_key=True, nullable=False),
- Column('instance_uuid', String(36, ForeignKey('instances.uuid'))),
- Column('code', Integer(), nullable=False),
- Column('message',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('details',
- Text(length=None, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- )
- try:
- instance_faults.create()
- except Exception:
- LOG.info(repr(instance_faults))
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- instance_faults = Table('instance_faults', meta, autoload=True)
- instance_faults.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py b/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py
deleted file mode 100644
index 8d4115a0b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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 select, Column, ForeignKey, Integer
-from sqlalchemy import MetaData, String, Table
-from migrate import ForeignKeyConstraint
-
-from nova import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- instance_actions = Table('instance_actions', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- uuid_column = Column('instance_uuid', String(36))
- uuid_column.create(instance_actions)
-
- try:
- instance_actions.update().values(
- instance_uuid=select(
- [instances.c.uuid],
- instances.c.id == instance_actions.c.instance_id)
- ).execute()
- except Exception:
- uuid_column.drop()
- raise
-
- if not dialect.startswith('sqlite'):
- fkeys = list(instance_actions.c.instance_id.foreign_keys)
- if fkeys:
- try:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[instance_actions.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
- instance_actions.c.instance_id.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instance_actions = Table('instance_actions', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- id_column = Column('instance_id', Integer, ForeignKey('instances.id'))
- id_column.create(instance_actions)
-
- try:
- instance_actions.update().values(
- instance_id=select(
- [instances.c.id],
- instances.c.uuid == instance_actions.c.instance_uuid)
- ).execute()
- except Exception:
- id_column.drop()
- raise
-
- instance_actions.c.instance_uuid.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/065_add_index_to_instance_project_id.py b/nova/db/sqlalchemy/migrate_repo/versions/065_add_index_to_instance_project_id.py
deleted file mode 100644
index 9b27f39dc..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/065_add_index_to_instance_project_id.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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 upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- index = Index('project_id', instances.c.project_id)
- index.create(migrate_engine)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- index = Index('project_id', instances.c.project_id)
- index.drop(migrate_engine)
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/066_preload_instance_info_cache_table.py b/nova/db/sqlalchemy/migrate_repo/versions/066_preload_instance_info_cache_table.py
deleted file mode 100644
index 15b667288..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/066_preload_instance_info_cache_table.py
+++ /dev/null
@@ -1,244 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-# 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 json
-
-from sqlalchemy import select, MetaData, Table
-
-from nova import ipv6
-from nova import log as logging
-from nova import utils
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- # grab tables
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
- instances = Table('instances', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- floating_ips = Table('floating_ips', meta, autoload=True)
-
- # all of these functions return a python list of python dicts
- # that have nothing to do with sqlalchemy objects whatsoever
- # after returning
- def get_instances():
- # want all instances whether there is network info or not
- s = select([instances.c.id, instances.c.uuid])
- keys = ('id', 'uuid')
-
- return [dict(zip(keys, row)) for row in s.execute()]
-
- def get_vifs_by_instance_id(instance_id):
- s = select([vifs.c.id, vifs.c.uuid, vifs.c.address, vifs.c.network_id],
- vifs.c.instance_id == instance_id)
- keys = ('id', 'uuid', 'address', 'network_id')
- return [dict(zip(keys, row)) for row in s.execute()]
-
- def get_network_by_id(network_id):
- s = select([networks.c.uuid, networks.c.label,
- networks.c.project_id,
- networks.c.dns1, networks.c.dns2,
- networks.c.cidr, networks.c.cidr_v6,
- networks.c.gateway, networks.c.gateway_v6,
- networks.c.injected, networks.c.multi_host,
- networks.c.bridge, networks.c.bridge_interface,
- networks.c.vlan],
- networks.c.id == network_id)
- keys = ('uuid', 'label', 'project_id', 'dns1', 'dns2',
- 'cidr', 'cidr_v6', 'gateway', 'gateway_v6',
- 'injected', 'multi_host', 'bridge', 'bridge_interface', 'vlan')
- return [dict(zip(keys, row)) for row in s.execute()]
-
- def get_fixed_ips_by_vif_id(vif_id):
- s = select([fixed_ips.c.id, fixed_ips.c.address],
- fixed_ips.c.virtual_interface_id == vif_id)
- keys = ('id', 'address')
- fixed_ip_list = [dict(zip(keys, row)) for row in s.execute()]
-
- # fixed ips have floating ips, so here they are
- for fixed_ip in fixed_ip_list:
- fixed_ip['version'] = 4
- fixed_ip['floating_ips'] = get_floating_ips_by_fixed_ip_id(
- fixed_ip['id'])
- fixed_ip['type'] = 'fixed'
- del fixed_ip['id']
-
- return fixed_ip_list
-
- def get_floating_ips_by_fixed_ip_id(fixed_ip_id):
- s = select([floating_ips.c.address],
- floating_ips.c.fixed_ip_id == fixed_ip_id)
- keys = ('address')
- floating_ip_list = [dict(zip(keys, row)) for row in s.execute()]
-
- for floating_ip in floating_ip_list:
- floating_ip['version'] = 4
- floating_ip['type'] = 'floating'
-
- return floating_ip_list
-
- def _ip_dict_from_string(ip_string, type):
- if ip_string:
- ip = {'address': ip_string,
- 'type': type}
- if ':' in ip_string:
- ip['version'] = 6
- else:
- ip['version'] = 4
-
- return ip
-
- def _get_fixed_ipv6_dict(cidr, mac, project_id):
- ip_string = ipv6.to_global(cidr, mac, project_id)
- return {'version': 6,
- 'address': ip_string,
- 'floating_ips': []}
-
- def _create_subnet(version, network, vif):
- if version == 4:
- cidr = network['cidr']
- gateway = network['gateway']
- ips = get_fixed_ips_by_vif_id(vif['id'])
- else:
- cidr = network['cidr_v6']
- gateway = network['gateway_v6']
- ips = [_get_fixed_ipv6_dict(network['cidr_v6'],
- vif['address'],
- network['project_id'])]
-
- # NOTE(tr3buchet) routes is left empty for now because there
- # is no good way to generate them or determine which is default
- subnet = {'version': version,
- 'cidr': cidr,
- 'dns': [],
- 'gateway': _ip_dict_from_string(gateway, 'gateway'),
- 'routes': [],
- 'ips': ips}
-
- if network['dns1'] and network['dns1']['version'] == version:
- subnet['dns'].append(network['dns1'])
- if network['dns2'] and network['dns2']['version'] == version:
- subnet['dns'].append(network['dns2'])
-
- return subnet
-
- def _update_network(vif, network):
- # vifs have a network which has subnets, so create the subnets
- # subnets contain all of the ip information
- network['subnets'] = []
-
- network['dns1'] = _ip_dict_from_string(network['dns1'], 'dns')
- network['dns2'] = _ip_dict_from_string(network['dns2'], 'dns')
-
- # nova networks can only have 2 subnets
- if network['cidr']:
- network['subnets'].append(_create_subnet(4, network, vif))
- if network['cidr_v6']:
- network['subnets'].append(_create_subnet(6, network, vif))
-
- # put network together to fit model
- network['id'] = network.pop('uuid')
- network['meta'] = {}
-
- # NOTE(tr3buchet) this isn't absolutely necessary as hydration
- # would still work with these as keys, but cache generated by
- # the model would show these keys as a part of meta. i went
- # ahead and set it up the same way just so it looks the same
- if network['project_id']:
- network['meta']['project_id'] = network['project_id']
- del network['project_id']
- if network['injected']:
- network['meta']['injected'] = network['injected']
- del network['injected']
- if network['multi_host']:
- network['meta']['multi_host'] = network['multi_host']
- del network['multi_host']
- if network['bridge_interface']:
- network['meta']['bridge_interface'] = network['bridge_interface']
- del network['bridge_interface']
- if network['vlan']:
- network['meta']['vlan'] = network['vlan']
- del network['vlan']
-
- # ip information now lives in the subnet, pull them out of network
- del network['dns1']
- del network['dns2']
- del network['cidr']
- del network['cidr_v6']
- del network['gateway']
- del network['gateway_v6']
-
- # don't need meta if it's empty
- if not network['meta']:
- del network['meta']
-
- # preload caches table
- # list is made up of a row(instance_id, nw_info_json) for each instance
- for instance in get_instances():
- LOG.info("Updating %s" % (instance['uuid']))
- instance_id = instance['id']
- instance_uuid = instance['uuid']
-
- # instances have vifs so aninstance nw_info is
- # is a list of dicts, 1 dict for each vif
- nw_info = get_vifs_by_instance_id(instance_id)
- LOG.info("VIFs for Instance %s: \n %s" %
- (instance['uuid'], nw_info))
- for vif in nw_info:
- networks_ = get_network_by_id(vif['network_id'])
- if networks_:
- network = networks_[0]
- LOG.info("Network for Instance %s: \n %s" %
- (instance['uuid'], network))
- _update_network(vif, network)
- else:
- network = None
-
- # put vif together to fit model
- del vif['network_id']
- vif['id'] = vif.pop('uuid')
- vif['network'] = network
- # vif['meta'] could also be set to contain rxtx data here
- # but it isn't exposed in the api and is still being rewritten
-
- LOG.info("VIF network for instance %s: \n %s" %
- (instance['uuid'], vif['network']))
-
- # jsonify nw_info
- row = {'created_at': utils.utcnow(),
- 'updated_at': utils.utcnow(),
- 'instance_id': instance_uuid,
- 'network_info': json.dumps(nw_info)}
-
- # write write row to table
- insert = instance_info_caches.insert().values(**row)
- migrate_engine.execute(insert)
-
-
-def downgrade(migrate_engine):
- # facepalm
- meta = MetaData()
- meta.bind = migrate_engine
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
-
- # there is really no way to know what data was added by the migration and
- # what was added afterward. Of note is the fact that before this migration
- # the cache table was empty; therefore, delete everything. Also, aliens.
- instance_info_caches.delete()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/067_add_pool_and_interface_to_floating_ip.py b/nova/db/sqlalchemy/migrate_repo/versions/067_add_pool_and_interface_to_floating_ip.py
deleted file mode 100644
index 6ba930db8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/067_add_pool_and_interface_to_floating_ip.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
-# 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
-
-from nova import flags
-
-flags.DECLARE('default_floating_pool', 'nova.network.manager')
-flags.DECLARE('public_interface', 'nova.network.linux_net')
-FLAGS = flags.FLAGS
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- table = Table('floating_ips', meta, autoload=True)
-
- pool_column = Column('pool', String(255))
- interface_column = Column('interface', String(255))
- table.create_column(pool_column)
- table.create_column(interface_column)
- table.update().values(pool=FLAGS.default_floating_pool,
- interface=FLAGS.public_interface).execute()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- table = Table('floating_ips', meta, autoload=True)
- table.c.pool.drop()
- table.c.interface.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/067_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/067_sqlite_downgrade.sql
deleted file mode 100644
index 3cd12cbdc..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/067_sqlite_downgrade.sql
+++ /dev/null
@@ -1,69 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE floating_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- pool VARCHAR(255),
- interface VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(fixed_ip_id) REFERENCES fixed_ips (id)
- );
-
- INSERT INTO floating_ips_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- fixed_ip_id,
- project_id,
- host,
- auto_assigned,
- pool,
- interface
- FROM floating_ips;
-
- DROP TABLE floating_ips;
-
- CREATE TABLE floating_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(fixed_ip_id) REFERENCES fixed_ips (id)
- );
-
- INSERT INTO floating_ips
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- address,
- fixed_ip_id,
- project_id,
- host,
- auto_assigned
- FROM floating_ips_backup;
-
- DROP TABLE floating_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/068_add_instance_attribute.py b/nova/db/sqlalchemy/migrate_repo/versions/068_add_instance_attribute.py
deleted file mode 100644
index a65aff8b4..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/068_add_instance_attribute.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2011 Isaku Yamahata
-#
-# 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
-from sqlalchemy import Column, MetaData, Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- shutdown_terminate = Column(
- 'shutdown_terminate', Boolean(), default=True)
- disable_terminate = Column(
- 'disable_terminate', Boolean(), default=False)
- instances.create_column(shutdown_terminate)
- instances.create_column(disable_terminate)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- instances.drop_column('shutdown_terminate')
- instances.drop_column('disable_terminate')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/068_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/068_sqlite_downgrade.sql
deleted file mode 100644
index a7700f6fa..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/068_sqlite_downgrade.sql
+++ /dev/null
@@ -1,219 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE instances_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_local_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- auto_disk_config BOOLEAN,
- shutdown_terminate BOOLEAN,
- disable_terminate BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1)),
- CHECK (auto_disk_config IN (0, 1)),
- CHECK (shutdown_terminate IN (0, 1)),
- CHECK (disable_terminate IN (0, 1))
- );
-
- INSERT INTO instances_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress,
- auto_disk_config,
- shutdown_terminate,
- disable_terminate
- FROM instances;
-
- DROP TABLE instances;
-
- CREATE TABLE instances(
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_local_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- auto_disk_config BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1)),
- CHECK (auto_disk_config IN (0, 1))
- );
-
- CREATE INDEX project_id ON instances (project_id);
- CREATE UNIQUE INDEX uuid ON instances (uuid);
-
- INSERT INTO instances
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress,
- auto_disk_config
- FROM instances_backup;
-
- DROP TABLE instances_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/069_block_migration.py b/nova/db/sqlalchemy/migrate_repo/versions/069_block_migration.py
deleted file mode 100644
index 14a3db35d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/069_block_migration.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# 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, Integer, MetaData, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- disk_available_least = Column('disk_available_least', Integer(), default=0)
- compute_nodes = Table('compute_nodes', meta, autoload=True)
- # Add disk_available_least column to compute_nodes table.
- # Thinking about qcow2 image support, both compressed and virtual disk size
- # has to be considered.
- # disk_available stores "total disk size - used disk(compressed disk size)"
- # while disk_available_least stores
- # "total disk size - used disk(virtual disk size)".
- # virtual disk size is used for kvm block migration.
- try:
- compute_nodes.create_column(disk_available_least)
- except Exception:
- LOG.error(_("progress column not added to compute_nodes table"))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- compute_nodes = Table('compute_nodes', meta, autoload=True)
- compute_nodes.drop_column('disk_available_least')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_downgrade.sql
deleted file mode 100644
index 5837603c8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_downgrade.sql
+++ /dev/null
@@ -1,103 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TABLE fixed_ips_backup (
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- host VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- CREATE TABLE floating_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- pool VARCHAR(255),
- interface VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- virtual_interface_id, network_id, instance_id, allocated,
- leased, reserved, host
- FROM fixed_ips;
-
- INSERT INTO floating_ips_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- fixed_ip_id, project_id, host, auto_assigned, pool,
- interface
- FROM floating_ips;
-
- DROP TABLE fixed_ips;
- DROP TABLE floating_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- host VARCHAR(255),
- PRIMARY KEY (id),
- FOREIGN KEY(virtual_interface_id) REFERENCES virtual_interfaces (id),
- FOREIGN KEY(network_id) REFERENCES networks (id),
- FOREIGN KEY(instance_id) REFERENCES instances (id)
- );
-
- CREATE TABLE floating_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- pool VARCHAR(255),
- interface VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(fixed_ip_id) REFERENCES fixed_ips (id)
- );
-
- INSERT INTO fixed_ips
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- virtual_interface_id, network_id, instance_id, allocated,
- leased, reserved, host
- FROM fixed_ips_backup;
-
- INSERT INTO floating_ips
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- fixed_ip_id, project_id, host, auto_assigned, pool,
- interface
- FROM floating_ips_backup;
-
- DROP TABLE fixed_ips_backup;
- DROP TABLE floating_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_upgrade.sql
deleted file mode 100644
index 2b6f7c39a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/070_sqlite_upgrade.sql
+++ /dev/null
@@ -1,99 +0,0 @@
-BEGIN TRANSACTION;
- CREATE TABLE fixed_ips_backup (
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- host VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- CREATE TABLE floating_ips_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- pool VARCHAR(255),
- interface VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- INSERT INTO fixed_ips_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- virtual_interface_id, network_id, instance_id, allocated,
- leased, reserved, host
- FROM fixed_ips;
-
- INSERT INTO floating_ips_backup
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- fixed_ip_id, project_id, host, auto_assigned, pool,
- interface
- FROM floating_ips;
-
- DROP TABLE fixed_ips;
- DROP TABLE floating_ips;
-
- CREATE TABLE fixed_ips (
- created_at DATETIME NOT NULL,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN NOT NULL,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- virtual_interface_id INTEGER,
- network_id INTEGER,
- instance_id INTEGER,
- allocated BOOLEAN default FALSE,
- leased BOOLEAN default FALSE,
- reserved BOOLEAN default FALSE,
- host VARCHAR(255),
- PRIMARY KEY (id)
- );
-
- CREATE TABLE floating_ips (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- address VARCHAR(255),
- fixed_ip_id INTEGER,
- project_id VARCHAR(255),
- host VARCHAR(255),
- auto_assigned BOOLEAN,
- pool VARCHAR(255),
- interface VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO fixed_ips
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- virtual_interface_id, network_id, instance_id, allocated,
- leased, reserved, host
- FROM fixed_ips_backup;
-
- INSERT INTO floating_ips
- SELECT created_at, updated_at, deleted_at, deleted, id, address,
- fixed_ip_id, project_id, host, auto_assigned, pool,
- interface
- FROM floating_ips_backup;
-
- DROP TABLE fixed_ips_backup;
- DROP TABLE floating_ips_backup;
-
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/070_untie_nova_network_models.py b/nova/db/sqlalchemy/migrate_repo/versions/070_untie_nova_network_models.py
deleted file mode 100644
index b5e147342..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/070_untie_nova_network_models.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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 import ForeignKeyConstraint
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- instances = Table('instances', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- floating_ips = Table('floating_ips', meta, autoload=True)
-
- try:
- fkeys = list(fixed_ips.c.network_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[fixed_ips.c.network_id],
- refcolumns=[networks.c.id],
- name=fkey_name).drop()
-
- fkeys = list(fixed_ips.c.virtual_interface_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
- refcolumns=[vifs.c.id],
- name=fkey_name).drop()
-
- fkeys = list(fixed_ips.c.instance_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[fixed_ips.c.instance_id],
- refcolumns=[instances.c.id],
- name=fkey_name).drop()
-
- fkeys = list(floating_ips.c.fixed_ip_id.foreign_keys)
- if fkeys:
- fkey_name = fkeys[0].constraint.name
- ForeignKeyConstraint(columns=[floating_ips.c.fixed_ip_id],
- refcolumns=[fixed_ips.c.id],
- name=fkey_name).drop()
-
- except Exception:
- LOG.error(_("foreign key constraint couldn't be removed"))
- raise
-
-
-def downgrade(migrate_engine):
- # Operations to reverse the above upgrade go here.
- meta = MetaData()
- meta.bind = migrate_engine
- dialect = migrate_engine.url.get_dialect().name
- if dialect.startswith('sqlite'):
- return
-
- instances = Table('instances', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
- vifs = Table('virtual_interfaces', meta, autoload=True)
- fixed_ips = Table('fixed_ips', meta, autoload=True)
- floating_ips = Table('floating_ips', meta, autoload=True)
-
- try:
- ForeignKeyConstraint(columns=[fixed_ips.c.network_id],
- refcolumns=[networks.c.id]).create()
-
- ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
- refcolumns=[vifs.c.id]).create()
-
- ForeignKeyConstraint(columns=[fixed_ips.c.instance_id],
- refcolumns=[instances.c.id]).create()
-
- ForeignKeyConstraint(columns=[floating_ips.c.fixed_ip_id],
- refcolumns=[fixed_ips.c.id]).create()
- except Exception:
- LOG.error(_("foreign key constraint couldn't be added"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/071_add_host_aggregate_tables.py b/nova/db/sqlalchemy/migrate_repo/versions/071_add_host_aggregate_tables.py
deleted file mode 100644
index 99fe642d7..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/071_add_host_aggregate_tables.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# Copyright (c) 2011 Citrix Systems, Inc.
-#
-# 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, String, DateTime, Integer
-from sqlalchemy import MetaData, Column, ForeignKey, Table
-
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- #
- # New Tables
- #
- aggregates = Table('aggregates', 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, autoincrement=True),
- Column('name',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- unique=True),
- Column('operational_state',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- Column('availability_zone',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- )
-
- hosts = Table('aggregate_hosts', 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('host',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- unique=True),
- Column('aggregate_id', Integer(), ForeignKey('aggregates.id'),
- nullable=False),
- )
-
- metadata = Table('aggregate_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('aggregate_id',
- Integer(),
- ForeignKey('aggregates.id'),
- nullable=False),
- Column('key',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False),
- Column('value',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- nullable=False))
- tables = (aggregates, hosts, metadata)
- for table in tables:
- try:
- table.create()
- except Exception:
- LOG.exception(repr(table))
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- aggregates = Table('aggregates', meta, autoload=True)
- hosts = Table('aggregate_hosts', meta, autoload=True)
- metadata = Table('aggregate_metadata', meta, autoload=True)
- # table order matters, don't change
- for table in (hosts, metadata, aggregates):
- try:
- table.drop()
- except Exception:
- LOG.exception(repr(table))
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/072_add_dns_table.py b/nova/db/sqlalchemy/migrate_repo/versions/072_add_dns_table.py
deleted file mode 100644
index fbb3fbea8..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/072_add_dns_table.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 2012 Andrew Bogott for The Wikimedia 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, ForeignKey
-from sqlalchemy import MetaData, String, Table
-from nova import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- projects = Table('projects', meta, autoload=True)
-
- #
- # New Tables
- #
- dns_domains = Table('dns_domains', 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('domain',
- String(length=512, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- primary_key=True, nullable=False),
- Column('scope',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('availability_zone',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('project_id',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False),
- ForeignKey('projects.id'))
- )
- # create dns_domains table
- try:
- dns_domains.create()
- except Exception:
- LOG.error(_("Table |%s| not created!"), repr(dns_domains))
- raise
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # load tables for fk
- projects = Table('projects', meta, autoload=True)
-
- dns_domains = Table('dns_domains', meta, autoload=True)
- try:
- dns_domains.drop()
- except Exception:
- LOG.error(_("dns_domains table not dropped"))
- raise
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/072_mysql_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/072_mysql_upgrade.sql
deleted file mode 100644
index d11e82147..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/072_mysql_upgrade.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-CREATE TABLE dns_domains (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- domain VARCHAR(512) CHARACTER SET latin1 NOT NULL,
- scope VARCHAR(255),
- availability_zone VARCHAR(255),
- project_id VARCHAR(255),
- PRIMARY KEY (domain),
- CHECK (deleted IN (0, 1)),
- FOREIGN KEY(project_id) REFERENCES projects (id)
-);
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/073_add_capacity.py b/nova/db/sqlalchemy/migrate_repo/versions/073_add_capacity.py
deleted file mode 100644
index 5dfe910ca..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/073_add_capacity.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2011 OpenStack LLC.
-#
-# 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, Integer, MetaData, Table
-
-from nova import log as logging
-
-
-def upgrade(migrate_engine):
- # Upgrade operations go here. Don't create your own engine;
- # bind migrate_engine to your metadata
- meta = MetaData()
- meta.bind = migrate_engine
- compute_nodes = Table('compute_nodes', meta, autoload=True)
-
- #
- # New Columns
- #
- new_columns = [
- Column('free_ram_mb', Integer()),
- Column('free_disk_gb', Integer()),
- Column('current_workload', Integer()),
- Column('running_vms', Integer()),
- ]
- for column in new_columns:
- compute_nodes.create_column(column)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- compute_nodes = Table('compute_nodes', meta, autoload=True)
-
- for column in ('free_ram_mb',
- 'free_disk_gb',
- 'current_workload',
- 'running_vms'):
- compute_nodes.drop_column(column)
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
deleted file mode 100644
index 91cef2694..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/074_change_flavor_local_gb.py
+++ /dev/null
@@ -1,130 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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 select, Column, Integer, MetaData, Table
-
-from nova import exception
-from nova import flags
-
-FLAGS = flags.FLAGS
-
-
-def upgrade_libvirt(instances, instance_types):
- # Update instance_types first
- tiny = None
- for inst_type in instance_types.select().execute():
- if inst_type['name'] == 'm1.tiny':
- tiny = inst_type['id']
- root_gb = 0
- else:
- root_gb = 10
-
- instance_types.update()\
- .values(root_gb=root_gb,
- ephemeral_gb=inst_type['local_gb'])\
- .where(instance_types.c.id == inst_type['id'])\
- .execute()
-
- # then update instances following same pattern
- instances.update()\
- .values(root_gb=10,
- ephemeral_gb=instances.c.local_gb)\
- .execute()
-
- if tiny is not None:
- instances.update()\
- .values(root_gb=0,
- ephemeral_gb=instances.c.local_gb)\
- .where(instances.c.instance_type_id == tiny)\
- .execute()
-
-
-def upgrade_other(instances, instance_types):
- for table in (instances, instance_types):
- table.update().values(root_gb=table.c.local_gb,
- ephemeral_gb=0).execute()
-
-
-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 = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
-
- 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 = Table('instance_types', meta, autoload=True)
-
- for table in (instances, instance_types):
- root_gb = Column('root_gb', Integer)
- root_gb.create(table)
- ephemeral_gb = Column('ephemeral_gb', Integer)
- ephemeral_gb.create(table)
-
- # Since this migration is part of the work to get all drivers
- # working the same way, we need to treat the new root_gb and
- # ephemeral_gb columns differently depending on what the
- # driver implementation used to behave like.
- if FLAGS.connection_type == 'libvirt':
- upgrade_libvirt(instances, instance_types)
- else:
- upgrade_other(instances, instance_types)
-
- default_local_device = instances.c.default_local_device
- default_local_device.alter(name='default_ephemeral_device')
-
- for table in (instances, instance_types):
- table.drop_column('local_gb')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- instance_types = Table('instance_types', meta, autoload=True)
-
- for table in (instances, instance_types):
- local_gb = Column('local_gb', Integer)
- local_gb.create(table)
-
- try:
- for table in (instances, instance_types):
- if FLAGS.connection_type == 'libvirt':
- column = table.c.ephemeral_gb
- else:
- column = table.c.root_gb
- table.update().values(local_gb=column).execute()
- except Exception:
- for table in (instances, instance_types):
- table.drop_column('local_gb')
- raise
-
- default_ephemeral_device = instances.c.default_ephemeral_device
- default_ephemeral_device.alter(name='default_local_device')
-
- for table in (instances, instance_types):
- table.drop_column('root_gb')
- table.drop_column('ephemeral_gb')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/074_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/074_sqlite_upgrade.sql
deleted file mode 100644
index e2708111b..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/074_sqlite_upgrade.sql
+++ /dev/null
@@ -1,313 +0,0 @@
--- sqlalchemy-migrate is surprisingly broken when it comes to migrations
--- for sqlite. As a result, we have to do much of the work manually here
-
-BEGIN TRANSACTION;
- -- make backup of instance_types
- CREATE TEMPORARY TABLE instance_types_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- local_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_factor FLOAT,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (flavorid),
- CHECK (deleted IN (0, 1)),
- UNIQUE (name)
- );
-
- INSERT INTO instance_types_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- local_gb,
- swap,
- rxtx_factor,
- vcpu_weight,
- flavorid
- FROM instance_types;
-
- DROP TABLE instance_types;
-
- CREATE TABLE instance_types (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- root_gb INTEGER NOT NULL,
- ephemeral_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_factor FLOAT,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- UNIQUE (flavorid),
- CHECK (deleted IN (0, 1)),
- UNIQUE (name)
- );
-
- -- copy from backup to new table with root_gb set to local_gb and
- -- ephmeral_gb set to 0
- INSERT INTO instance_types
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- local_gb,
- 0,
- swap,
- rxtx_factor,
- vcpu_weight,
- flavorid
- FROM instance_types_backup;
-
- DROP TABLE instance_types_backup;
-
- -- make backup of instances
- CREATE TEMPORARY TABLE instances_backup (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- local_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_local_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- auto_disk_config BOOLEAN,
- shutdown_terminate BOOLEAN,
- disable_terminate BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1)),
- CHECK (auto_disk_config IN (0, 1)),
- CHECK (shutdown_terminate IN (0, 1)),
- CHECK (disable_terminate IN (0, 1))
- );
-
- INSERT INTO instances_backup
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress,
- auto_disk_config,
- shutdown_terminate,
- disable_terminate
- FROM instances;
-
- DROP TABLE instances;
-
- CREATE TABLE instances (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- internal_id INTEGER,
- user_id VARCHAR(255),
- project_id VARCHAR(255),
- image_ref VARCHAR(255),
- kernel_id VARCHAR(255),
- ramdisk_id VARCHAR(255),
- server_name VARCHAR(255),
- launch_index INTEGER,
- key_name VARCHAR(255),
- key_data TEXT,
- power_state INTEGER,
- vm_state VARCHAR(255),
- memory_mb INTEGER,
- vcpus INTEGER,
- root_gb INTEGER,
- ephemeral_gb INTEGER,
- hostname VARCHAR(255),
- host VARCHAR(255),
- user_data TEXT,
- reservation_id VARCHAR(255),
- scheduled_at DATETIME,
- launched_at DATETIME,
- terminated_at DATETIME,
- display_name VARCHAR(255),
- display_description VARCHAR(255),
- availability_zone VARCHAR(255),
- locked BOOLEAN,
- os_type VARCHAR(255),
- launched_on TEXT,
- instance_type_id INTEGER,
- vm_mode VARCHAR(255),
- uuid VARCHAR(36),
- architecture VARCHAR(255),
- root_device_name VARCHAR(255),
- access_ip_v4 VARCHAR(255),
- access_ip_v6 VARCHAR(255),
- config_drive VARCHAR(255),
- task_state VARCHAR(255),
- default_ephemeral_device VARCHAR(255),
- default_swap_device VARCHAR(255),
- progress INTEGER,
- auto_disk_config BOOLEAN,
- shutdown_terminate BOOLEAN,
- disable_terminate BOOLEAN,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1)),
- CHECK (locked IN (0, 1)),
- CHECK (auto_disk_config IN (0, 1)),
- CHECK (shutdown_terminate IN (0, 1)),
- CHECK (disable_terminate IN (0, 1))
- );
-
- CREATE INDEX project_id ON instances (project_id);
- CREATE UNIQUE INDEX uuid ON instances (uuid);
-
- -- copy from backup to new table with root_gb set to local_gb and
- -- ephmeral_gb set to 0
- INSERT INTO instances
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- internal_id,
- user_id,
- project_id,
- image_ref,
- kernel_id,
- ramdisk_id,
- server_name,
- launch_index,
- key_name,
- key_data,
- power_state,
- vm_state,
- memory_mb,
- vcpus,
- local_gb,
- 0,
- hostname,
- host,
- user_data,
- reservation_id,
- scheduled_at,
- launched_at,
- terminated_at,
- display_name,
- display_description,
- availability_zone,
- locked,
- os_type,
- launched_on,
- instance_type_id,
- vm_mode,
- uuid,
- architecture,
- root_device_name,
- access_ip_v4,
- access_ip_v6,
- config_drive,
- task_state,
- default_local_device,
- default_swap_device,
- progress,
- auto_disk_config,
- shutdown_terminate,
- disable_terminate
- FROM instances_backup;
-
- DROP TABLE instances_backup;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/075_convert_bw_usage_to_store_network_id.py b/nova/db/sqlalchemy/migrate_repo/versions/075_convert_bw_usage_to_store_network_id.py
deleted file mode 100644
index b275524ab..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/075_convert_bw_usage_to_store_network_id.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2011 OpenStack LLC.
-# 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 and_, select
-from sqlalchemy import BigInteger, Boolean, Column, DateTime
-from sqlalchemy import Integer, MetaData, String
-from sqlalchemy import Table
-
-from nova import utils
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- vifs = Table('virtual_interfaces', meta, autoload=True)
- networks = Table('networks', meta, autoload=True)
-
- bw_usage_cache = Table('bw_usage_cache', 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('instance_id', Integer(), nullable=False),
- Column('network_label',
- String(length=255, convert_unicode=False,
- assert_unicode=None,
- unicode_error=None, _warn_on_bytestring=False)),
- Column('start_period', DateTime(timezone=False),
- nullable=False),
- Column('last_refreshed', DateTime(timezone=False)),
- Column('bw_in', BigInteger()),
- Column('bw_out', BigInteger()),
- useexisting=True)
- mac_column = Column('mac', String(255))
- bw_usage_cache.create_column(mac_column)
-
- bw_usage_cache.update()\
- .values(mac=select([vifs.c.address])\
- .where(and_(
- networks.c.label == bw_usage_cache.c.network_label,
- networks.c.id == vifs.c.network_id,
- bw_usage_cache.c.instance_id == vifs.c.instance_id))\
- .as_scalar()).execute()
-
- bw_usage_cache.c.network_label.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- vifs = Table('virtual_interfaces', meta, autoload=True)
- network = Table('networks', meta, autoload=True)
-
- bw_usage_cache = Table('bw_usage_cache', 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('instance_id', Integer(), nullable=False),
- Column('mac', String(255)),
- Column('start_period', DateTime(timezone=False),
- nullable=False),
- Column('last_refreshed', DateTime(timezone=False)),
- Column('bw_in', BigInteger()),
- Column('bw_out', BigInteger()),
- useexisting=True)
-
- network_label_column = Column('network_label', String(255))
- bw_usage_cache.create_column(network_label_column)
-
- bw_usage_cache.update()\
- .values(network_label=select([network.c.label])\
- .where(and_(
- network.c.id == vifs.c.network_id,
- vifs.c.address == bw_usage_cache.c.mac,
- bw_usage_cache.c.instance_id == vifs.c.instance_id))\
- .as_scalar()).execute()
-
- bw_usage_cache.c.mac.drop()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/076_remove_unique_constraints.py b/nova/db/sqlalchemy/migrate_repo/versions/076_remove_unique_constraints.py
deleted file mode 100644
index 971bfbecc..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/076_remove_unique_constraints.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) OpenStack, LLC
-# 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 *
-
-from sqlalchemy import MetaData, Table
-from migrate.changeset.constraint import UniqueConstraint
-
-
-def _get_constraint_names(engine_name):
-
- # NOTE(vish): These constraint names may be dependent on the backend, but
- # there doesn't seem to be we a way to determine the proper
- # name for existing constraints. These names are correct for
- # mysql and postgres.
- if engine_name == "mysql":
- return {
- "instance_types_name": ("name", "instance_types_name_key"),
- "instance_types_flavorid": "instance_types_flavorid_str_key",
- "volume_types_name": "name",
- }
- else:
- return {
- "instance_types_name": ("instance_types_name_key",),
- "instance_types_flavorid": "instance_types_flavorid_str_key",
- "volume_types_name": "volume_types_name_key",
- }
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- c_names = _get_constraint_names(migrate_engine.name)
-
- table = Table('instance_types', meta, autoload=True)
- for constraint_name in c_names['instance_types_name']:
- cons = UniqueConstraint('name',
- name=constraint_name,
- table=table)
- cons.drop()
- cons = UniqueConstraint('flavorid',
- name=c_names['instance_types_flavorid'],
- table=table)
- cons.drop()
- table = Table('volume_types', meta, autoload=True)
- cons = UniqueConstraint('name',
- name=c_names['volume_types_name'],
- table=table)
- cons.drop()
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- c_names = _get_constraint_names(migrate_engine.name)
-
- table = Table('instance_types', meta, autoload=True)
- for constraint_name in c_names['instance_types_name']:
- cons = UniqueConstraint('name',
- name=constraint_name,
- table=table)
- cons.create()
- table = Table('instance_types', meta, autoload=True)
- cons = UniqueConstraint('flavorid',
- name=c_names['instance_types_flavorid'],
- table=table)
- cons.create()
- table = Table('volume_types', meta, autoload=True)
- cons = UniqueConstraint('name',
- name=c_names['volume_types_name'],
- table=table)
- cons.create()
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/076_sqlite_upgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/076_sqlite_upgrade.sql
deleted file mode 100644
index 6053c1ed7..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/076_sqlite_upgrade.sql
+++ /dev/null
@@ -1,61 +0,0 @@
--- sqlalchemy-migrate is surprisingly broken when it comes to migrations
--- for sqlite. As a result, we have to do much of the work manually here
-
-BEGIN TRANSACTION;
- CREATE TABLE instance_types_temp (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- memory_mb INTEGER NOT NULL,
- vcpus INTEGER NOT NULL,
- root_gb INTEGER NOT NULL,
- ephemeral_gb INTEGER NOT NULL,
- swap INTEGER NOT NULL,
- rxtx_factor FLOAT,
- vcpu_weight INTEGER,
- flavorid VARCHAR(255),
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO instance_types_temp SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id,
- memory_mb,
- vcpus,
- root_gb,
- ephemeral_gb,
- swap,
- rxtx_factor,
- vcpu_weight,
- flavorid
- FROM instance_types;
- DROP TABLE instance_types;
- ALTER TABLE instance_types_temp RENAME TO instance_types;
- CREATE TABLE volume_types_temp (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- name VARCHAR(255),
- id INTEGER NOT NULL,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1))
- );
- INSERT INTO volume_types_temp SELECT
- created_at,
- updated_at,
- deleted_at,
- deleted,
- name,
- id
- FROM volume_types;
- DROP TABLE volume_types;
- ALTER TABLE volume_types_temp RENAME TO volume_types;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/077_convert_to_utf8.py b/nova/db/sqlalchemy/migrate_repo/versions/077_convert_to_utf8.py
deleted file mode 100644
index 4c08e2f0d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/077_convert_to_utf8.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack LLC.
-# 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 MetaData
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- # NOTE (ironcamel): The only table we are not converting to utf8 here is
- # dns_domains. This table has a primary key that is 512 characters wide.
- # When the mysql engine attempts to convert it to utf8, it complains about
- # not supporting key columns larger than 1000.
-
- if migrate_engine.name == "mysql":
- tables = [
- # tables that are FK parents, must be converted early
- "aggregates", "console_pools", "instance_types", "instances",
- "projects", "security_groups", "sm_backend_config", "sm_flavors",
- "snapshots", "user_project_association", "users", "volume_types",
- "volumes",
- # those that are children and others later
- "agent_builds", "aggregate_hosts", "aggregate_metadata",
- "auth_tokens", "block_device_mapping", "bw_usage_cache",
- "certificates", "compute_nodes", "consoles", "fixed_ips",
- "floating_ips", "instance_actions", "instance_faults",
- "instance_info_caches", "instance_metadata",
- "instance_type_extra_specs", "iscsi_targets", "key_pairs",
- "migrate_version", "migrations", "networks", "provider_fw_rules",
- "quotas", "s3_images", "security_group_instance_association",
- "security_group_rules", "services", "sm_volume",
- "user_project_role_association", "user_role_association",
- "virtual_interfaces", "virtual_storage_arrays", "volume_metadata",
- "volume_type_extra_specs", "zones"]
- sql = "SET foreign_key_checks = 0;"
- for table in tables:
- sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
- sql += "SET foreign_key_checks = 1;"
- sql += "ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" \
- % migrate_engine.url.database
- migrate_engine.execute(sql)
-
-
-def downgrade(migrate_engine):
- # utf8 tables should be backwards compatible, so lets leave it alone
- pass
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/078_add_rpc_info_to_zones.py b/nova/db/sqlalchemy/migrate_repo/versions/078_add_rpc_info_to_zones.py
deleted file mode 100644
index e4043f84d..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/078_add_rpc_info_to_zones.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# 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
-from sqlalchemy import Integer, MetaData, String
-from sqlalchemy import Table
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- is_parent = Column('is_parent', Boolean(), default=False)
- rpc_host = Column('rpc_host', String(255))
- rpc_port = Column('rpc_port', Integer())
- rpc_virtual_host = Column('rpc_virtual_host', String(255))
-
- zones.create_column(is_parent)
- zones.create_column(rpc_host)
- zones.create_column(rpc_port)
- zones.create_column(rpc_virtual_host)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- zones = Table('zones', meta, autoload=True)
-
- zones.drop_column('rpc_virtual_host')
- zones.drop_column('rpc_port')
- zones.drop_column('rpc_host')
- zones.drop_column('is_parent')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/078_sqlite_downgrade.sql b/nova/db/sqlalchemy/migrate_repo/versions/078_sqlite_downgrade.sql
deleted file mode 100644
index 80061af78..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/078_sqlite_downgrade.sql
+++ /dev/null
@@ -1,35 +0,0 @@
-BEGIN TRANSACTION;
-
- CREATE TEMPORARY TABLE zones_temp (
- created_at DATETIME,
- updated_at DATETIME,
- deleted_at DATETIME,
- deleted BOOLEAN,
- id INTEGER NOT NULL,
- name VARCHAR(255),
- api_url VARCHAR(255),
- username VARCHAR(255),
- password VARCHAR(255),
- weight_offset FLOAT,
- weight_scale FLOAT,
- PRIMARY KEY (id),
- CHECK (deleted IN (0, 1))
- );
-
- INSERT INTO zones_temp
- SELECT created_at,
- updated_at,
- deleted_at,
- deleted,
- id,
- name,
- api_url,
- username,
- password,
- weight_offset,
- weight_scale FROM zones;
-
- DROP TABLE zones;
-
- ALTER TABLE zones_temp RENAME TO zones;
-COMMIT;
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/079_add_zone_name_to_instances.py b/nova/db/sqlalchemy/migrate_repo/versions/079_add_zone_name_to_instances.py
deleted file mode 100644
index 2b22b94a0..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/079_add_zone_name_to_instances.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# 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
- instances = Table('instances', meta, autoload=True)
- zone_name = Column('zone_name', String(255))
- instances.create_column(zone_name)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- instances.drop_column('zone_name')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/080_add_hypervisor_hostname_to_compute_nodes.py b/nova/db/sqlalchemy/migrate_repo/versions/080_add_hypervisor_hostname_to_compute_nodes.py
deleted file mode 100644
index 28a3ce48f..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/080_add_hypervisor_hostname_to_compute_nodes.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2012 OpenStack, LLC
-#
-# 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
- compute_nodes = Table("compute_nodes", meta, autoload=True)
- hypervisor_hostname = Column("hypervisor_hostname", String(255))
- compute_nodes.create_column(hypervisor_hostname)
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- compute_nodes = Table("compute_nodes", meta, autoload=True)
- compute_nodes.drop_column('hypervisor_hostname')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/081_drop_instance_id_bw_cache.py b/nova/db/sqlalchemy/migrate_repo/versions/081_drop_instance_id_bw_cache.py
deleted file mode 100644
index c6687ac80..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/081_drop_instance_id_bw_cache.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright (c) 2011 OpenStack, LLC.
-# 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 json
-
-from sqlalchemy import Column, Table, MetaData, Integer, Boolean, String
-from sqlalchemy import DateTime, BigInteger
-
-
-def upgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- bw_usage_cache = Table('bw_usage_cache', 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('instance_id', Integer(), nullable=False),
- Column('mac', String(255)),
- Column('start_period', DateTime(timezone=False),
- nullable=False),
- Column('last_refreshed', DateTime(timezone=False)),
- Column('bw_in', BigInteger()),
- Column('bw_out', BigInteger()),
- useexisting=True)
-
- bw_usage_cache.drop_column('instance_id')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
-
- instance_info_caches = Table('instance_info_caches', meta, autoload=True)
- bw_usage_cache = Table('bw_usage_cache', meta, autoload=True)
-
- instance_id = Column('instance_id', Integer)
- bw_usage_cache.create_column(instance_id)
-
- cache = {}
- for row in migrate_engine.execute(instance_info_caches.select()):
- instance_id = row['instance']['id']
- if not row['network_info']:
- continue
-
- nw_info = json.loads(row['network_info'])
- for vif in nw_info:
- cache[vif['address']] = instance_id
-
- for row in migrate_engine.execute(bw_usage_cache.select()):
- instance_id = cache[row['mac']]
- migrate_engine.execute(bw_usage_cache.update()\
- .where(bw_usage_cache.c.id == row['id'])\
- .values(instance_id=instance_id))
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py
new file mode 100644
index 000000000..f4eab7e77
--- /dev/null
+++ b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py
@@ -0,0 +1,981 @@
+from sqlalchemy import Boolean, BigInteger, Column, DateTime, Float, ForeignKey
+from sqlalchemy import Index, Integer, MetaData, String, Table, Text
+from migrate import ForeignKeyConstraint
+from nova import log as logging
+from nova import flags
+
+from sets import Set
+
+FLAGS = flags.FLAGS
+
+LOG = logging.getLogger(__name__)
+
+
+def _populate_instance_types(instance_types_table):
+ if FLAGS.connection_type == "libvirt":
+ default_inst_types = {
+ 'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1),
+ 'm1.small': dict(mem=2048, vcpus=1, root_gb=10, eph_gb=20, flavid=2),
+ 'm1.medium': dict(mem=4096, vcpus=2, root_gb=10, eph_gb=40, flavid=3),
+ 'm1.large': dict(mem=8192, vcpus=4, root_gb=10, eph_gb=80, flavid=4),
+ 'm1.xlarge': dict(mem=16384, vcpus=8, root_gb=10, eph_gb=160, flavid=5)
+ }
+ else:
+ default_inst_types = {
+ 'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1),
+ 'm1.small': dict(mem=2048, vcpus=1, root_gb=20, eph_gb=0, flavid=2),
+ 'm1.medium': dict(mem=4096, vcpus=2, root_gb=40, eph_gb=0, flavid=3),
+ 'm1.large': dict(mem=8192, vcpus=4, root_gb=80, eph_gb=0, flavid=4),
+ 'm1.xlarge': dict(mem=16384, vcpus=8, root_gb=160, eph_gb=0, flavid=5)
+ }
+
+ try:
+ i = instance_types_table.insert()
+ for name, values in default_inst_types.iteritems():
+ i.execute({'name': name, 'memory_mb': values["mem"],
+ 'vcpus': values["vcpus"], 'deleted': False,
+ 'root_gb': values["root_gb"],
+ 'ephemeral_gb': values["eph_gb"],
+ 'rxtx_factor': 1,
+ 'swap': 0,
+ 'flavorid': values["flavid"]})
+ except Exception:
+ LOG.info(repr(instance_types_table))
+ LOG.exception('Exception while seeding instance_types table')
+ raise
+
+
+def upgrade(migrate_engine):
+ meta = MetaData()
+ meta.bind = migrate_engine
+ dialect = migrate_engine.url.get_dialect().name
+
+ agent_builds = Table('agent_builds', 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('hypervisor', String(length=255)),
+ Column('os', String(length=255)),
+ Column('architecture', String(length=255)),
+ Column('version', String(length=255)),
+ Column('url', String(length=255)),
+ Column('md5hash', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ aggregate_hosts = Table('aggregate_hosts', 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), unique=True),
+ Column('aggregate_id', Integer, ForeignKey('aggregates.id'),
+ nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ aggregate_metadata = Table('aggregate_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('aggregate_id', Integer, ForeignKey('aggregates.id'),
+ nullable=False),
+ Column('key', String(length=255), nullable=False),
+ Column('value', String(length=255), nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ aggregates = Table('aggregates', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, nullable=False,
+ autoincrement=True),
+ Column('name', String(length=255), unique=True),
+ Column('operational_state', String(length=255), nullable=False),
+ Column('availability_zone', String(length=255), nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ auth_tokens = Table('auth_tokens', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('token_hash', String(length=255), primary_key=True,
+ nullable=False),
+ Column('user_id', String(length=255)),
+ Column('server_management_url', String(length=255)),
+ Column('storage_url', String(length=255)),
+ Column('cdn_management_url', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ block_device_mapping = Table('block_device_mapping', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer, primary_key=True, autoincrement=True,
+ nullable=False),
+ Column('instance_id', Integer, ForeignKey('instances.id'),
+ nullable=False),
+ Column('device_name', String(length=255), nullable=False),
+ Column('delete_on_termination', Boolean),
+ Column('virtual_name', String(length=255)),
+ Column('snapshot_id', Integer, ForeignKey('snapshots.id'),
+ nullable=True),
+ Column('volume_id', Integer(), ForeignKey('volumes.id'),
+ nullable=True),
+ Column('volume_size', Integer),
+ Column('no_device', Boolean),
+ Column('connection_info', Text),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ bw_usage_cache = Table('bw_usage_cache', 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('start_period', DateTime, nullable=False),
+ Column('last_refreshed', DateTime),
+ Column('bw_in', BigInteger),
+ Column('bw_out', BigInteger),
+ Column('mac', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ cells = Table('cells', 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('api_url', String(length=255)),
+ Column('username', String(length=255)),
+ Column('password', String(length=255)),
+ Column('weight_offset', Float),
+ Column('weight_scale', Float),
+ Column('name', String(length=255)),
+ Column('is_parent', Boolean),
+ Column('rpc_host', String(length=255)),
+ Column('rpc_port', Integer),
+ Column('rpc_virtual_host', String(length=255)),
+ mysql_engine='InnoDB',
+ mysql_charset='utf8'
+ )
+
+ certificates = Table('certificates', 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('user_id', String(length=255)),
+ Column('project_id', String(length=255)),
+ Column('file_name', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ compute_nodes = Table('compute_nodes', 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('service_id', Integer, nullable=False),
+ Column('vcpus', Integer, nullable=False),
+ Column('memory_mb', Integer, nullable=False),
+ Column('local_gb', Integer, nullable=False),
+ Column('vcpus_used', Integer, nullable=False),
+ Column('memory_mb_used', Integer, nullable=False),
+ Column('local_gb_used', Integer, nullable=False),
+ Column('hypervisor_type', Text, nullable=False),
+ Column('hypervisor_version', Integer, nullable=False),
+ Column('cpu_info', Text, nullable=False),
+ Column('disk_available_least', Integer),
+ Column('free_ram_mb', Integer),
+ Column('free_disk_gb', Integer),
+ Column('current_workload', Integer),
+ Column('running_vms', Integer),
+ Column('hypervisor_hostname', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ console_pools = Table('console_pools', 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('address', String(length=255)),
+ Column('username', String(length=255)),
+ Column('password', String(length=255)),
+ Column('console_type', String(length=255)),
+ Column('public_hostname', String(length=255)),
+ Column('host', String(length=255)),
+ Column('compute_host', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ consoles = Table('consoles', 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('instance_name', String(length=255)),
+ Column('instance_id', Integer),
+ Column('password', String(length=255)),
+ Column('port', Integer),
+ Column('pool_id', Integer, ForeignKey('console_pools.id')),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ # NOTE(dprince): Trying to create a fresh utf8 dns_domains tables
+ # with a domain primary key length of 512 fails w/
+ # 'Specified key was too long; max key length is 767 bytes'.
+ # See: https://bugs.launchpad.net/nova/+bug/993663
+ # If we fix this during Folsom we can set mysql_charset=utf8 inline...
+ # and remove the unsightly loop that does it below during "E" compaction.
+ dns_domains = Table('dns_domains', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('domain', String(length=512), primary_key=True, nullable=False),
+ Column('scope', String(length=255)),
+ Column('availability_zone', String(length=255)),
+ Column('project_id', String(length=255), ForeignKey('projects.id')),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ fixed_ips = Table('fixed_ips', 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('address', String(length=255)),
+ Column('network_id', Integer),
+ Column('instance_id', Integer),
+ Column('allocated', Boolean),
+ Column('leased', Boolean),
+ Column('reserved', Boolean),
+ Column('virtual_interface_id', Integer),
+ Column('host', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ floating_ips = Table('floating_ips', 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('address', String(length=255)),
+ Column('fixed_ip_id', Integer),
+ Column('project_id', String(length=255)),
+ Column('host', String(length=255)),
+ Column('auto_assigned', Boolean),
+ Column('pool', String(length=255)),
+ Column('interface', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_actions = Table('instance_actions', 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('action', String(length=255)),
+ Column('error', Text),
+ Column('instance_uuid', String(length=36)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_faults = Table('instance_faults', 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('instance_uuid', String(length=36)),
+ Column('code', Integer, nullable=False),
+ Column('message', String(length=255)),
+ Column('details', Text),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_info_caches = Table('instance_info_caches', 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('network_info', Text),
+ Column('instance_id', String(36), nullable=False, unique=True),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_metadata = Table('instance_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('instance_id', Integer, ForeignKey('instances.id'),
+ nullable=False),
+ Column('key', String(length=255)),
+ Column('value', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_type_extra_specs = Table('instance_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('instance_type_id', Integer, ForeignKey('instance_types.id'),
+ nullable=False),
+ Column('key', String(length=255)),
+ Column('value', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instance_types = Table('instance_types', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('name', String(length=255)),
+ Column('id', Integer, primary_key=True, nullable=False),
+ Column('memory_mb', Integer, nullable=False),
+ Column('vcpus', Integer, nullable=False),
+ Column('swap', Integer, nullable=False),
+ Column('vcpu_weight', Integer),
+ Column('flavorid', String(length=255)),
+ Column('rxtx_factor', Float),
+ Column('root_gb', Integer),
+ Column('ephemeral_gb', Integer),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instances = Table('instances', 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('internal_id', Integer),
+ Column('user_id', String(length=255)),
+ Column('project_id', String(length=255)),
+ Column('image_ref', String(length=255)),
+ Column('kernel_id', String(length=255)),
+ Column('ramdisk_id', String(length=255)),
+ Column('server_name', String(length=255)),
+ Column('launch_index', Integer),
+ Column('key_name', String(length=255)),
+ Column('key_data', Text),
+ Column('power_state', Integer),
+ Column('vm_state', String(length=255)),
+ Column('memory_mb', Integer),
+ Column('vcpus', Integer),
+ Column('hostname', String(length=255)),
+ Column('host', String(length=255)),
+ Column('user_data', Text),
+ Column('reservation_id', 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('availability_zone', String(length=255)),
+ Column('locked', Boolean),
+ Column('os_type', String(length=255)),
+ Column('launched_on', Text),
+ Column('instance_type_id', Integer),
+ Column('vm_mode', String(length=255)),
+ Column('uuid', String(length=36)),
+ Column('architecture', String(length=255)),
+ Column('root_device_name', String(length=255)),
+ Column('access_ip_v4', String(length=255)),
+ Column('access_ip_v6', String(length=255)),
+ Column('config_drive', String(length=255)),
+ Column('task_state', String(length=255)),
+ Column('default_ephemeral_device', String(length=255)),
+ Column('default_swap_device', String(length=255)),
+ Column('progress', Integer),
+ Column('auto_disk_config', Boolean),
+ Column('shutdown_terminate', Boolean),
+ Column('disable_terminate', Boolean),
+ Column('root_gb', Integer),
+ Column('ephemeral_gb', Integer),
+ Column('cell_name', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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', Integer, ForeignKey('volumes.id'),
+ nullable=True),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ key_pairs = Table('key_pairs', 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)),
+ Column('user_id', String(length=255)),
+ Column('fingerprint', String(length=255)),
+ Column('public_key', Text),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ networks = Table('networks', 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('injected', Boolean),
+ Column('cidr', String(length=255)),
+ Column('netmask', String(length=255)),
+ Column('bridge', String(length=255)),
+ Column('gateway', String(length=255)),
+ Column('broadcast', String(length=255)),
+ Column('dns1', String(length=255)),
+ Column('vlan', Integer),
+ Column('vpn_public_address', String(length=255)),
+ Column('vpn_public_port', Integer),
+ Column('vpn_private_address', String(length=255)),
+ Column('dhcp_start', String(length=255)),
+ Column('project_id', String(length=255)),
+ Column('host', String(length=255)),
+ Column('cidr_v6', String(length=255)),
+ Column('gateway_v6', String(length=255)),
+ Column('label', String(length=255)),
+ Column('netmask_v6', String(length=255)),
+ Column('bridge_interface', String(length=255)),
+ Column('multi_host', Boolean),
+ Column('dns2', String(length=255)),
+ Column('uuid', String(length=36)),
+ Column('priority', Integer),
+ Column('rxtx_base', Integer),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ projects = Table('projects', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', String(length=255), primary_key=True, nullable=False),
+ Column('name', String(length=255)),
+ Column('description', String(length=255)),
+ Column('project_manager', String(length=255), ForeignKey('users.id')),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ provider_fw_rules = Table('provider_fw_rules', 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('protocol', String(length=5)),
+ Column('from_port', Integer),
+ Column('to_port', Integer),
+ Column('cidr', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ s3_images = Table('s3_images', 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('uuid', String(length=36), nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ security_group_instance_association = \
+ Table('security_group_instance_association', 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('security_group_id', Integer, ForeignKey('security_groups.id')),
+ Column('instance_id', Integer, ForeignKey('instances.id')),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ security_group_rules = Table('security_group_rules', 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('parent_group_id', Integer, ForeignKey('security_groups.id')),
+ Column('protocol', String(length=255)),
+ Column('from_port', Integer),
+ Column('to_port', Integer),
+ Column('cidr', String(length=255)),
+ Column('group_id', Integer, ForeignKey('security_groups.id')),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ security_groups = Table('security_groups', 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)),
+ Column('description', String(length=255)),
+ Column('user_id', String(length=255)),
+ Column('project_id', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ sm_volume = Table('sm_volume', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', Integer(), ForeignKey('volumes.id'), primary_key=True,
+ nullable=False, autoincrement=False),
+ Column('backend_id', Integer, ForeignKey('sm_backend_config.id'),
+ nullable=False),
+ Column('vdi_uuid', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ snapshots = Table('snapshots', 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', Integer, 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',
+ #mysql_charset='utf8'
+ )
+
+ user_project_association = Table('user_project_association', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('user_id', String(length=255), primary_key=True,
+ nullable=False),
+ Column('project_id', String(length=255), primary_key=True,
+ nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ user_project_role_association = \
+ Table('user_project_role_association', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('user_id', String(length=255), primary_key=True,
+ nullable=False),
+ Column('project_id', String(length=255), primary_key=True,
+ nullable=False),
+ Column('role', String(length=255), primary_key=True, nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ user_role_association = Table('user_role_association', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('user_id', String(length=255), ForeignKey('users.id'),
+ primary_key=True, nullable=False),
+ Column('role', String(length=255), primary_key=True, nullable=False),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ users = Table('users', meta,
+ Column('created_at', DateTime),
+ Column('updated_at', DateTime),
+ Column('deleted_at', DateTime),
+ Column('deleted', Boolean),
+ Column('id', String(length=255), primary_key=True, nullable=False),
+ Column('name', String(length=255)),
+ Column('access_key', String(length=255)),
+ Column('secret_key', String(length=255)),
+ Column('is_admin', Boolean),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ virtual_interfaces = Table('virtual_interfaces', 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('address', String(length=255), unique=True),
+ Column('network_id', Integer),
+ Column('instance_id', Integer, nullable=False),
+ Column('uuid', String(length=36)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ virtual_storage_arrays = Table('virtual_storage_arrays', 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('display_name', String(length=255)),
+ Column('display_description', String(length=255)),
+ Column('project_id', String(length=255)),
+ Column('availability_zone', String(length=255)),
+ Column('instance_type_id', Integer, nullable=False),
+ Column('image_ref', String(length=255)),
+ Column('vc_count', Integer, nullable=False),
+ Column('vol_count', Integer, nullable=False),
+ Column('status', String(length=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', Integer, primary_key=True, nullable=False),
+ Column('name', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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', Integer, ForeignKey('volumes.id'),
+ nullable=False),
+ Column('key', String(length=255)),
+ Column('value', String(length=255)),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ 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',
+ #mysql_charset='utf8'
+ )
+
+ volumes = Table('volumes', 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('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_id', Integer, ForeignKey('instances.id')),
+ 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', Integer),
+ Column('volume_type_id', Integer),
+ mysql_engine='InnoDB',
+ #mysql_charset='utf8'
+ )
+
+ instances.create()
+ Index('uuid', instances.c.uuid, unique=True).create(migrate_engine)
+ Index('project_id', instances.c.project_id).create(migrate_engine)
+
+ # create all tables
+ tables = [aggregates, console_pools, instance_types,
+ users, projects, security_groups, sm_flavors, sm_backend_config,
+ snapshots, user_project_association, volume_types,
+ volumes,
+ # those that are children and others later
+ agent_builds, aggregate_hosts, aggregate_metadata,
+ auth_tokens, block_device_mapping, bw_usage_cache, cells,
+ certificates, compute_nodes, consoles, dns_domains, fixed_ips,
+ floating_ips, instance_actions, instance_faults,
+ instance_info_caches, instance_metadata,
+ instance_type_extra_specs, iscsi_targets, key_pairs,
+ migrations, networks, provider_fw_rules,
+ quotas, s3_images, security_group_instance_association,
+ security_group_rules, services, sm_volume,
+ user_project_role_association, user_role_association,
+ virtual_interfaces, virtual_storage_arrays, volume_metadata,
+ volume_type_extra_specs]
+
+ for table in tables:
+ try:
+ table.create()
+ except Exception:
+ LOG.info(repr(table))
+ LOG.exception('Exception while creating table.')
+ raise
+
+ # MySQL specific Indexes from Essex
+ # NOTE(dprince): I think some of these can be removed in Folsom
+ indexes = [
+ Index('network_id', fixed_ips.c.network_id),
+ Index('instance_id', fixed_ips.c.instance_id),
+ Index('fixed_ips_virtual_interface_id_fkey',
+ fixed_ips.c.virtual_interface_id),
+ Index('fixed_ip_id', floating_ips.c.fixed_ip_id),
+ Index('project_id', user_project_association.c.project_id),
+ Index('network_id', virtual_interfaces.c.network_id),
+ Index('instance_id', virtual_interfaces.c.instance_id),
+ ]
+
+ if migrate_engine.name == 'mysql':
+ for index in indexes:
+ index.create(migrate_engine)
+
+ fkeys = [
+ [[user_project_role_association.c.user_id,
+ user_project_role_association.c.project_id],
+ [user_project_association.c.user_id,
+ user_project_association.c.project_id],
+ 'user_project_role_association_ibfk_1'],
+ [[user_project_association.c.user_id],
+ [users.c.id], 'user_project_association_ibfk_1'],
+ [[user_project_association.c.project_id], [projects.c.id],
+ 'user_project_association_ibfk_2'],
+ [[instance_info_caches.c.instance_id], [instances.c.uuid],
+ 'instance_info_caches_ibfk_1'],
+ ]
+
+ for fkey_pair in fkeys:
+ if migrate_engine.name == 'mysql':
+ # For MySQL we name our fkeys explicitly so they match Essex
+ fkey = ForeignKeyConstraint(columns=fkey_pair[0],
+ refcolumns=fkey_pair[1],
+ name=fkey_pair[2])
+ fkey.create()
+ elif migrate_engine.name == 'postgresql':
+ fkey = ForeignKeyConstraint(columns=fkey_pair[0],
+ refcolumns=fkey_pair[1])
+ fkey.create()
+
+ # Hopefully this entire loop to set the charset can go away during
+ # the "E" release compaction. See the notes on the dns_domains
+ # table above for why this is required vs. setting mysql_charset inline.
+ if migrate_engine.name == "mysql":
+ tables = [
+ # tables that are FK parents, must be converted early
+ "aggregates", "console_pools", "instance_types", "instances",
+ "projects", "security_groups", "sm_backend_config", "sm_flavors",
+ "snapshots", "user_project_association", "users", "volume_types",
+ "volumes",
+ # those that are children and others later
+ "agent_builds", "aggregate_hosts", "aggregate_metadata",
+ "auth_tokens", "block_device_mapping", "bw_usage_cache",
+ "certificates", "compute_nodes", "consoles", "fixed_ips",
+ "floating_ips", "instance_actions", "instance_faults",
+ "instance_info_caches", "instance_metadata",
+ "instance_type_extra_specs", "iscsi_targets", "key_pairs",
+ "migrate_version", "migrations", "networks", "provider_fw_rules",
+ "quotas", "s3_images", "security_group_instance_association",
+ "security_group_rules", "services", "sm_volume",
+ "user_project_role_association", "user_role_association",
+ "virtual_interfaces", "virtual_storage_arrays", "volume_metadata",
+ "volume_type_extra_specs"]
+ sql = "SET foreign_key_checks = 0;"
+ for table in tables:
+ sql += "ALTER TABLE %s CONVERT TO CHARACTER SET utf8;" % table
+ sql += "SET foreign_key_checks = 1;"
+ sql += "ALTER DATABASE %s DEFAULT CHARACTER SET utf8;" \
+ % migrate_engine.url.database
+ migrate_engine.execute(sql)
+
+ if migrate_engine.name == "postgresql":
+ # NOTE(dprince): Need to rename the leftover zones stuff.
+ # https://bugs.launchpad.net/nova/+bug/993667
+ sql = "ALTER TABLE cells_id_seq RENAME TO zones_id_seq;"
+ sql += "ALTER TABLE ONLY cells DROP CONSTRAINT cells_pkey;"
+ sql += "ALTER TABLE ONLY cells ADD CONSTRAINT zones_pkey" \
+ " PRIMARY KEY (id);"
+
+ # NOTE(dprince): Need to rename the leftover quota_new stuff.
+ # https://bugs.launchpad.net/nova/+bug/993669
+ sql += "ALTER TABLE quotas_id_seq RENAME TO quotas_new_id_seq;"
+ sql += "ALTER TABLE ONLY quotas DROP CONSTRAINT quotas_pkey;"
+ sql += "ALTER TABLE ONLY quotas ADD CONSTRAINT quotas_new_pkey" \
+ " PRIMARY KEY (id);"
+
+ migrate_engine.execute(sql)
+
+ # populate initial instance types
+ _populate_instance_types(instance_types)
+
+
+def downgrade(migrate_engine):
+ LOG.exception('Downgrade from Essex is unsupported.')
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py b/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py
deleted file mode 100644
index 79e99503a..000000000
--- a/nova/db/sqlalchemy/migrate_repo/versions/082_zone_to_cell.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2012 OpenStack LLC.
-#
-# 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
- instances = Table('instances', meta, autoload=True)
- zone_name = instances.c.zone_name
- zone_name.alter(name='cell_name')
- zones = Table('zones', meta, autoload=True)
- zones.rename('cells')
-
-
-def downgrade(migrate_engine):
- meta = MetaData()
- meta.bind = migrate_engine
- instances = Table('instances', meta, autoload=True)
- cell_name = instances.c.cell_name
- cell_name.alter(name='zone_name')
- cells = Table('cells', meta, autoload=True)
- cells.rename('zones')
diff --git a/nova/db/sqlalchemy/migration.py b/nova/db/sqlalchemy/migration.py
index d46dc98b3..befb4cbec 100644
--- a/nova/db/sqlalchemy/migration.py
+++ b/nova/db/sqlalchemy/migration.py
@@ -20,6 +20,7 @@ import distutils.version as dist_version
import os
import sys
+from nova.db import migration
from nova.db.sqlalchemy.session import get_engine
from nova import exception
from nova import flags
@@ -87,29 +88,17 @@ def db_version():
try:
return versioning_api.db_version(get_engine(), repository)
except versioning_exceptions.DatabaseNotControlledError:
- # If we aren't version controlled we may already have the database
- # in the state from before we started version control, check for that
- # and set up version_control appropriately
meta = sqlalchemy.MetaData()
engine = get_engine()
meta.reflect(bind=engine)
- try:
- for table in ('auth_tokens', 'zones', 'export_devices',
- 'fixed_ips', 'floating_ips', 'instances',
- 'key_pairs', 'networks', 'projects', 'quotas',
- 'security_group_instance_association',
- 'security_group_rules', 'security_groups',
- 'services', 'migrations',
- 'users', 'user_project_association',
- 'user_project_role_association',
- 'user_role_association',
- 'virtual_storage_arrays',
- 'volumes', 'volume_metadata',
- 'volume_types', 'volume_type_extra_specs'):
- assert table in meta.tables
- return db_version_control(1)
- except AssertionError:
- return db_version_control(0)
+ tables = meta.tables
+ if len(tables) == 0:
+ db_version_control(migration.INIT_VERSION)
+ return versioning_api.db_version(get_engine(), repository)
+ else:
+ # Some pre-Essex DB's may not be version controlled.
+ # Require them to upgrade using Essex first.
+ raise exception.Error(_("Upgrade DB using Essex release first."))
def db_version_control(version=None):
diff --git a/nova/tests/__init__.py b/nova/tests/__init__.py
index 0e33cd7ac..31e19020c 100644
--- a/nova/tests/__init__.py
+++ b/nova/tests/__init__.py
@@ -50,7 +50,8 @@ def reset_db():
engine = get_engine()
engine.dispose()
conn = engine.connect()
- conn.connection.executescript(_DB)
+ if _DB:
+ conn.connection.executescript(_DB)
else:
shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db),
os.path.join(FLAGS.state_path, FLAGS.sqlite_db))
@@ -69,7 +70,7 @@ def setup():
from nova.tests import fake_flags
if FLAGS.sql_connection == "sqlite://":
- if migration.db_version() > 1:
+ if migration.db_version() > migration.INIT_VERSION:
return
else:
testdb = os.path.join(FLAGS.state_path, FLAGS.sqlite_db)
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 0e36236bc..cdc90a46e 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -33,6 +33,7 @@ from migrate.versioning import repository
import sqlalchemy
import nova.db.sqlalchemy.migrate_repo
+import nova.db.migration as migration
from nova.db.sqlalchemy.migration import versioning_api as migration_api
from nova import log as logging
from nova import test
@@ -253,14 +254,19 @@ class TestMigrations(test.TestCase):
# upgrades successfully.
# Place the database under version control
- migration_api.version_control(engine, TestMigrations.REPOSITORY)
- self.assertEqual(0,
+ migration_api.version_control(engine, TestMigrations.REPOSITORY,
+ migration.INIT_VERSION)
+ self.assertEqual(migration.INIT_VERSION,
migration_api.db_version(engine,
TestMigrations.REPOSITORY))
+ migration_api.upgrade(engine, TestMigrations.REPOSITORY,
+ migration.INIT_VERSION + 1)
+
LOG.debug('latest version is %s' % TestMigrations.REPOSITORY.latest)
- for version in xrange(1, TestMigrations.REPOSITORY.latest + 1):
+ for version in xrange(migration.INIT_VERSION + 2,
+ TestMigrations.REPOSITORY.latest + 1):
# upgrade -> downgrade -> upgrade
self._migrate_up(engine, version)
if snake_walk:
@@ -271,7 +277,8 @@ class TestMigrations(test.TestCase):
# Now walk it back down to 0 from the latest, testing
# the downgrade paths.
for version in reversed(
- xrange(0, TestMigrations.REPOSITORY.latest)):
+ xrange(migration.INIT_VERSION + 1,
+ TestMigrations.REPOSITORY.latest)):
# downgrade -> upgrade -> downgrade
self._migrate_down(engine, version)
if snake_walk: