1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2010 United States Government as represented by the
4
# Administrator of the National Aeronautics and Space Administration.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
from sqlalchemy import Boolean, Column, DateTime, Integer, MetaData
20
from sqlalchemy import Table, Text
21
from nova import log as logging
23
LOG = logging.getLogger(__name__)
26
def upgrade(migrate_engine):
27
# Upgrade operations go here. Don't create your own engine;
28
# bind migrate_engine to your metadata
30
meta.bind = migrate_engine
32
instances = Table('instances', meta, autoload=True)
34
compute_nodes = Table('compute_nodes', meta,
35
Column('created_at', DateTime(timezone=False)),
36
Column('updated_at', DateTime(timezone=False)),
37
Column('deleted_at', DateTime(timezone=False)),
38
Column('deleted', Boolean(create_constraint=True, name=None)),
39
Column('id', Integer(), primary_key=True, nullable=False),
40
Column('service_id', Integer(), nullable=False),
42
Column('vcpus', Integer(), nullable=False),
43
Column('memory_mb', Integer(), nullable=False),
44
Column('local_gb', Integer(), nullable=False),
45
Column('vcpus_used', Integer(), nullable=False),
46
Column('memory_mb_used', Integer(), nullable=False),
47
Column('local_gb_used', Integer(), nullable=False),
48
Column('hypervisor_type',
49
Text(convert_unicode=False, assert_unicode=None,
50
unicode_error=None, _warn_on_bytestring=False),
52
Column('hypervisor_version', Integer(), nullable=False),
54
Text(convert_unicode=False, assert_unicode=None,
55
unicode_error=None, _warn_on_bytestring=False),
60
compute_nodes.create()
62
LOG.info(repr(compute_nodes))
63
LOG.exception('Exception while creating table')
64
meta.drop_all(tables=[compute_nodes])
67
instances_launched_on = Column(
69
Text(convert_unicode=False, assert_unicode=None,
70
unicode_error=None, _warn_on_bytestring=False),
72
instances.create_column(instances_launched_on)
75
def downgrade(migrate_engine):
77
meta.bind = migrate_engine
79
instances = Table('instances', meta, autoload=True)
81
compute_nodes = Table('compute_nodes', meta, autoload=True)
85
instances.drop_column('launched_on')