diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-03-13 20:08:14 -0400 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-03-14 15:32:16 -0400 |
| commit | ed02460ebe08faebc64f1d88aa53cca54f1e45cc (patch) | |
| tree | 1bbc4c25da6f232e2ed6e4a7eff95307a4546dde /nova/db | |
| parent | fee9425d3ece2358717a74319073db6ba0cab9f5 (diff) | |
| download | nova-ed02460ebe08faebc64f1d88aa53cca54f1e45cc.tar.gz nova-ed02460ebe08faebc64f1d88aa53cca54f1e45cc.tar.xz nova-ed02460ebe08faebc64f1d88aa53cca54f1e45cc.zip | |
Fix system_metadata "None" and created_at values
The ill-fated migration 153 converted None instance_type values to
"None" in the database instead of properly making them NULL. This
corrects that by sweeping all of the likely instance_type_% values and
converting "None" to NULL. Also, it adds a belated created_at stamp
to all of the items, which was missing in 153 as well.
It also corrects the 153 migration to avoid polluting things in the
first place for systems that haven't rolled through that yet.
Fixes bug 1152546
Change-Id: I3585463ae15abfd534f2ff070e2974f3cb51d7e8
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/153_instance_type_in_system_metadata.py | 3 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/migrate_repo/versions/161_fix_system_metadata_none_strings.py | 43 |
2 files changed, 45 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/migrate_repo/versions/153_instance_type_in_system_metadata.py b/nova/db/sqlalchemy/migrate_repo/versions/153_instance_type_in_system_metadata.py index 20e75a6eb..36545b435 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/153_instance_type_in_system_metadata.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/153_instance_type_in_system_metadata.py @@ -38,8 +38,9 @@ def upgrade(migrate_engine): i = sys_meta.insert() for values in q.execute(): for index in range(0, len(instance_type_props)): + value = values[index + 1] i.execute({"key": "instance_type_%s" % instance_type_props[index], - "value": str(values[index + 1]), + "value": None if value is None else str(value), "instance_uuid": values[0]}) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/161_fix_system_metadata_none_strings.py b/nova/db/sqlalchemy/migrate_repo/versions/161_fix_system_metadata_none_strings.py new file mode 100644 index 000000000..bd8f22a97 --- /dev/null +++ b/nova/db/sqlalchemy/migrate_repo/versions/161_fix_system_metadata_none_strings.py @@ -0,0 +1,43 @@ +# Copyright 2013 IBM Corp. +# +# 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 nova.openstack.common import timeutils + + +def upgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + sys_meta = Table('instance_system_metadata', meta, autoload=True) + + sys_meta.update().\ + values(value=None).\ + where(sys_meta.c.key != 'instance_type_name').\ + where(sys_meta.c.key != 'instance_type_flavorid').\ + where(sys_meta.c.key.like('instance_type_%')).\ + where(sys_meta.c.value == 'None').\ + execute() + + now = timeutils.utcnow() + sys_meta.update().\ + values(created_at=now).\ + where(sys_meta.c.created_at == None).\ + where(sys_meta.c.key.like('instance_type_%')).\ + execute() + + +def downgrade(migration_engine): + # This migration only touches data, and only metadata at that. No need + # to go through and delete old metadata items. + pass |
