~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/062_add_instance_info_cache_table.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2011 OpenStack LLC.
2
 
# All Rights Reserved.
3
 
#
4
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
 
#    not use this file except in compliance with the License. You may obtain
6
 
#    a copy of the License at
7
 
#
8
 
#         http://www.apache.org/licenses/LICENSE-2.0
9
 
#
10
 
#    Unless required by applicable law or agreed to in writing, software
11
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 
#    License for the specific language governing permissions and limitations
14
 
#    under the License.
15
 
 
16
 
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
17
 
from sqlalchemy import Integer, MetaData, String
18
 
from sqlalchemy import Table, Text
19
 
 
20
 
from nova import log as logging
21
 
from nova import utils
22
 
 
23
 
LOG = logging.getLogger(__name__)
24
 
 
25
 
 
26
 
def upgrade(migrate_engine):
27
 
    meta = MetaData()
28
 
    meta.bind = migrate_engine
29
 
 
30
 
    # load tables for fk
31
 
    instances = Table('instances', meta, autoload=True)
32
 
 
33
 
    #
34
 
    # New Tables
35
 
    #
36
 
    instance_info_caches = Table('instance_info_caches', meta,
37
 
            Column('created_at', DateTime(timezone=False),
38
 
                   default=utils.utcnow()),
39
 
            Column('updated_at', DateTime(timezone=False),
40
 
                   onupdate=utils.utcnow()),
41
 
            Column('deleted_at', DateTime(timezone=False)),
42
 
            Column('deleted', Boolean(create_constraint=True, name=None)),
43
 
            Column('id', Integer(), primary_key=True),
44
 
            Column('network_info', Text()),
45
 
            Column('instance_id', String(36),
46
 
                   ForeignKey('instances.uuid'),
47
 
                   nullable=False,
48
 
                   unique=True),
49
 
            mysql_engine='InnoDB')
50
 
    # create instance_info_caches table
51
 
    try:
52
 
        instance_info_caches.create()
53
 
    except Exception:
54
 
        LOG.error(_("Table |%s| not created!"), repr(instance_info_caches))
55
 
        raise
56
 
 
57
 
 
58
 
def downgrade(migrate_engine):
59
 
    meta = MetaData()
60
 
    meta.bind = migrate_engine
61
 
 
62
 
    # load tables for fk
63
 
    instances = Table('instances', meta, autoload=True)
64
 
 
65
 
    instance_info_caches = Table('instance_info_caches', meta, autoload=True)
66
 
    try:
67
 
        instance_info_caches.drop()
68
 
    except Exception:
69
 
        LOG.error(_("instance_info_caches tables not dropped"))
70
 
        raise