~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/117_add_compute_node_stats.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman, Adam Gandelman, Chuck Short
  • Date: 2012-08-27 15:37:18 UTC
  • mfrom: (1.1.60)
  • Revision ID: package-import@ubuntu.com-20120827153718-lj8er44eqqz1gsrj
Tags: 2012.2~rc1~20120827.15815-0ubuntu1
[ Adam Gandelman ]
* New upstream release.

[ Chuck Short ]
* debian/patches/0001-Update-tools-hacking-for-pep8-1.2-and-
  beyond.patch: Dropped we dont run pep8 tests anymore.
* debian/control: Drop pep8 build depends
* debian/*.upstart.in: Make sure we transition correctly from runlevel
  1 to 2. (LP: #820694)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2012 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, Integer
 
17
from sqlalchemy import Index, MetaData, String, Table
 
18
from nova.openstack.common import log as logging
 
19
 
 
20
LOG = logging.getLogger(__name__)
 
21
 
 
22
 
 
23
def upgrade(migrate_engine):
 
24
    meta = MetaData()
 
25
    meta.bind = migrate_engine
 
26
 
 
27
    # load tables for fk
 
28
    compute_nodes = Table('compute_nodes', meta, autoload=True)
 
29
 
 
30
    # create new table
 
31
    compute_node_stats = Table('compute_node_stats', meta,
 
32
            Column('created_at', DateTime(timezone=False)),
 
33
            Column('updated_at', DateTime(timezone=False)),
 
34
            Column('deleted_at', DateTime(timezone=False)),
 
35
            Column('deleted', Boolean(create_constraint=True, name=None)),
 
36
            Column('id', Integer(), primary_key=True, nullable=False,
 
37
                autoincrement=True),
 
38
            Column('compute_node_id', Integer, index=True, nullable=False),
 
39
            Column('key', String(length=255, convert_unicode=True,
 
40
                assert_unicode=None, unicode_error=None,
 
41
                _warn_on_bytestring=False), nullable=False),
 
42
            Column('value', String(length=255, convert_unicode=True,
 
43
                assert_unicode=None, unicode_error=None,
 
44
                _warn_on_bytestring=False)),
 
45
            mysql_engine='InnoDB')
 
46
    try:
 
47
        compute_node_stats.create()
 
48
    except Exception:
 
49
        LOG.exception("Exception while creating table 'compute_node_stats'")
 
50
        raise
 
51
 
 
52
 
 
53
def downgrade(migrate_engine):
 
54
    meta = MetaData()
 
55
    meta.bind = migrate_engine
 
56
 
 
57
    # load tables for fk
 
58
    compute_nodes = Table('compute_nodes', meta, autoload=True)
 
59
 
 
60
    compute_node_stats = Table('compute_node_stats', meta, autoload=True)
 
61
    compute_node_stats.drop()