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

« back to all changes in this revision

Viewing changes to .pc/0001-fix-useexisting-deprecation-warnings.patch/nova/db/sqlalchemy/migrate_repo/versions/075_convert_bw_usage_to_store_network_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
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2011 OpenStack LLC.
4
 
# All Rights Reserved.
5
 
#
6
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
 
#    not use this file except in compliance with the License. You may obtain
8
 
#    a copy of the License at
9
 
#
10
 
#         http://www.apache.org/licenses/LICENSE-2.0
11
 
#
12
 
#    Unless required by applicable law or agreed to in writing, software
13
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 
#    License for the specific language governing permissions and limitations
16
 
#    under the License.
17
 
 
18
 
from sqlalchemy import and_, select
19
 
from sqlalchemy import BigInteger, Boolean, Column, DateTime
20
 
from sqlalchemy import Integer, MetaData, String
21
 
from sqlalchemy import Table
22
 
 
23
 
from nova import utils
24
 
 
25
 
 
26
 
def upgrade(migrate_engine):
27
 
    meta = MetaData()
28
 
    meta.bind = migrate_engine
29
 
 
30
 
    vifs = Table('virtual_interfaces', meta, autoload=True)
31
 
    networks = Table('networks', meta, autoload=True)
32
 
 
33
 
    bw_usage_cache = Table('bw_usage_cache', meta,
34
 
                Column('created_at', DateTime(timezone=False)),
35
 
                Column('updated_at', DateTime(timezone=False)),
36
 
                Column('deleted_at', DateTime(timezone=False)),
37
 
                Column('deleted', Boolean(create_constraint=True, name=None)),
38
 
                Column('id', Integer(), primary_key=True, nullable=False),
39
 
                Column('instance_id', Integer(), nullable=False),
40
 
                Column('network_label',
41
 
                       String(length=255, convert_unicode=False,
42
 
                              assert_unicode=None,
43
 
                              unicode_error=None, _warn_on_bytestring=False)),
44
 
                Column('start_period', DateTime(timezone=False),
45
 
                       nullable=False),
46
 
                Column('last_refreshed', DateTime(timezone=False)),
47
 
                Column('bw_in', BigInteger()),
48
 
                Column('bw_out', BigInteger()),
49
 
                useexisting=True)
50
 
    mac_column = Column('mac', String(255))
51
 
    bw_usage_cache.create_column(mac_column)
52
 
 
53
 
    bw_usage_cache.update()\
54
 
        .values(mac=select([vifs.c.address])\
55
 
            .where(and_(
56
 
                    networks.c.label == bw_usage_cache.c.network_label,
57
 
                    networks.c.id == vifs.c.network_id,
58
 
                    bw_usage_cache.c.instance_id == vifs.c.instance_id))\
59
 
            .as_scalar()).execute()
60
 
 
61
 
    bw_usage_cache.c.network_label.drop()
62
 
 
63
 
 
64
 
def downgrade(migrate_engine):
65
 
    meta = MetaData()
66
 
    meta.bind = migrate_engine
67
 
 
68
 
    vifs = Table('virtual_interfaces', meta, autoload=True)
69
 
    network = Table('networks', meta, autoload=True)
70
 
 
71
 
    bw_usage_cache = Table('bw_usage_cache', meta,
72
 
                Column('created_at', DateTime(timezone=False)),
73
 
                Column('updated_at', DateTime(timezone=False)),
74
 
                Column('deleted_at', DateTime(timezone=False)),
75
 
                Column('deleted', Boolean(create_constraint=True, name=None)),
76
 
                Column('id', Integer(), primary_key=True, nullable=False),
77
 
                Column('instance_id', Integer(), nullable=False),
78
 
                Column('mac', String(255)),
79
 
                Column('start_period', DateTime(timezone=False),
80
 
                       nullable=False),
81
 
                Column('last_refreshed', DateTime(timezone=False)),
82
 
                Column('bw_in', BigInteger()),
83
 
                Column('bw_out', BigInteger()),
84
 
                useexisting=True)
85
 
 
86
 
    network_label_column = Column('network_label', String(255))
87
 
    bw_usage_cache.create_column(network_label_column)
88
 
 
89
 
    bw_usage_cache.update()\
90
 
        .values(network_label=select([network.c.label])\
91
 
            .where(and_(
92
 
                network.c.id == vifs.c.network_id,
93
 
               vifs.c.address == bw_usage_cache.c.mac,
94
 
               bw_usage_cache.c.instance_id == vifs.c.instance_id))\
95
 
            .as_scalar()).execute()
96
 
 
97
 
    bw_usage_cache.c.mac.drop()