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

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/031_fk_fixed_ips_virtual_interface_id.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 MetaData, Table
17
 
from migrate import ForeignKeyConstraint
18
 
 
19
 
from nova import log as logging
20
 
 
21
 
LOG = logging.getLogger(__name__)
22
 
 
23
 
 
24
 
def upgrade(migrate_engine):
25
 
    meta = MetaData()
26
 
    meta.bind = migrate_engine
27
 
    dialect = migrate_engine.url.get_dialect().name
28
 
 
29
 
    # grab tables
30
 
    fixed_ips = Table('fixed_ips', meta, autoload=True)
31
 
    virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
32
 
 
33
 
    # add foreignkey if not sqlite
34
 
    try:
35
 
        if not dialect.startswith('sqlite'):
36
 
            ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
37
 
                                 refcolumns=[virtual_interfaces.c.id]).create()
38
 
    except Exception:
39
 
        LOG.error(_("foreign key constraint couldn't be added"))
40
 
        raise
41
 
 
42
 
 
43
 
def downgrade(migrate_engine):
44
 
    meta = MetaData()
45
 
    meta.bind = migrate_engine
46
 
    dialect = migrate_engine.url.get_dialect().name
47
 
 
48
 
    # grab tables
49
 
    fixed_ips = Table('fixed_ips', meta, autoload=True)
50
 
    virtual_interfaces = Table('virtual_interfaces', meta, autoload=True)
51
 
 
52
 
    # drop foreignkey if not sqlite
53
 
    try:
54
 
        if not dialect.startswith('sqlite'):
55
 
            ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
56
 
                                 refcolumns=[virtual_interfaces.c.id]).drop()
57
 
    except Exception:
58
 
        LOG.error(_("foreign key constraint couldn't be dropped"))
59
 
        raise