~gandelman-a/ubuntu/precise/nova/UCA_2012.2.1

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/026_add_agent_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, Integer
17
 
from sqlalchemy import MetaData, String, Table
18
 
from nova import log as logging
19
 
 
20
 
 
21
 
LOG = logging.getLogger(__name__)
22
 
 
23
 
 
24
 
def upgrade(migrate_engine):
25
 
    # Upgrade operations go here. Don't create your own engine;
26
 
    # bind migrate_engine to your metadata
27
 
    meta = MetaData()
28
 
    meta.bind = migrate_engine
29
 
    #
30
 
    # New Tables
31
 
    #
32
 
    builds = Table('agent_builds', meta,
33
 
            Column('created_at', DateTime(timezone=False)),
34
 
            Column('updated_at', DateTime(timezone=False)),
35
 
            Column('deleted_at', DateTime(timezone=False)),
36
 
            Column('deleted', Boolean(create_constraint=True, name=None)),
37
 
            Column('id', Integer(), primary_key=True, nullable=False),
38
 
            Column('hypervisor',
39
 
                   String(length=255, convert_unicode=False,
40
 
                          assert_unicode=None,
41
 
                          unicode_error=None, _warn_on_bytestring=False)),
42
 
            Column('os',
43
 
                   String(length=255, convert_unicode=False,
44
 
                          assert_unicode=None,
45
 
                          unicode_error=None, _warn_on_bytestring=False)),
46
 
            Column('architecture',
47
 
                   String(length=255, convert_unicode=False,
48
 
                          assert_unicode=None,
49
 
                          unicode_error=None, _warn_on_bytestring=False)),
50
 
            Column('version',
51
 
                   String(length=255, convert_unicode=False,
52
 
                          assert_unicode=None,
53
 
                          unicode_error=None, _warn_on_bytestring=False)),
54
 
            Column('url',
55
 
                   String(length=255, convert_unicode=False,
56
 
                          assert_unicode=None,
57
 
                          unicode_error=None, _warn_on_bytestring=False)),
58
 
            Column('md5hash',
59
 
                   String(length=255, convert_unicode=False,
60
 
                          assert_unicode=None,
61
 
                          unicode_error=None, _warn_on_bytestring=False)),
62
 
            )
63
 
    for table in (builds, ):
64
 
        try:
65
 
            table.create()
66
 
        except Exception:
67
 
            LOG.info(repr(table))
68
 
 
69
 
    instances = Table('instances', meta, autoload=True)
70
 
 
71
 
    #
72
 
    # New Columns
73
 
    #
74
 
    architecture = Column('architecture', String(length=255))
75
 
 
76
 
    # Add columns to existing tables
77
 
    instances.create_column(architecture)
78
 
 
79
 
 
80
 
def downgrade(migrate_engine):
81
 
    meta = MetaData()
82
 
    meta.bind = migrate_engine
83
 
 
84
 
    builds = Table('agent_builds', meta, autoload=True)
85
 
    for table in (builds, ):
86
 
            table.drop()
87
 
 
88
 
    instances = Table('instances', meta, autoload=True)
89
 
    instances.drop_column('architecture')