~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/161_fix_system_metadata_none_strings.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, James Page
  • Date: 2013-03-20 12:59:22 UTC
  • mfrom: (1.1.69)
  • Revision ID: package-import@ubuntu.com-20130320125922-ohvfav96lemn9wlz
Tags: 1:2013.1~rc1-0ubuntu1
[ Chuck Short ]
* New upstream release.
* debian/patches/avoid_setuptools_git_dependency.patch: Refreshed.
* debian/control: Clean up dependencies:
  - Dropped python-gflags no longer needed.
  - Dropped python-daemon no longer needed.
  - Dropped python-glance no longer needed.
  - Dropped python-lockfile no longer needed.
  - Dropped python-simplejson no longer needed.
  - Dropped python-tempita no longer needed.
  - Dropped python-xattr no longer needed.
  - Add sqlite3 required for the testsuite.

[ James Page ]
* d/watch: Update uversionmangle to deal with upstream versioning
  changes, remove tarballs.openstack.org. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2013 IBM Corp.
 
2
#
 
3
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
#    not use this file except in compliance with the License. You may obtain
 
5
#    a copy of the License at
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
#    Unless required by applicable law or agreed to in writing, software
 
10
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
#    License for the specific language governing permissions and limitations
 
13
#    under the License.
 
14
 
 
15
from sqlalchemy import MetaData, Table
 
16
from nova.openstack.common import timeutils
 
17
 
 
18
 
 
19
def upgrade(migrate_engine):
 
20
    meta = MetaData()
 
21
    meta.bind = migrate_engine
 
22
    sys_meta = Table('instance_system_metadata', meta, autoload=True)
 
23
 
 
24
    sys_meta.update().\
 
25
        values(value=None).\
 
26
        where(sys_meta.c.key != 'instance_type_name').\
 
27
        where(sys_meta.c.key != 'instance_type_flavorid').\
 
28
        where(sys_meta.c.key.like('instance_type_%')).\
 
29
        where(sys_meta.c.value == 'None').\
 
30
        execute()
 
31
 
 
32
    now = timeutils.utcnow()
 
33
    sys_meta.update().\
 
34
        values(created_at=now).\
 
35
        where(sys_meta.c.created_at == None).\
 
36
        where(sys_meta.c.key.like('instance_type_%')).\
 
37
        execute()
 
38
 
 
39
 
 
40
def downgrade(migration_engine):
 
41
    # This migration only touches data, and only metadata at that. No need
 
42
    # to go through and delete old metadata items.
 
43
    pass