~ubuntu-branches/ubuntu/trusty/cinder/trusty

« back to all changes in this revision

Viewing changes to cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla Mota, James Page, Chuck Short
  • Date: 2013-02-22 10:45:17 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130222104517-ng3r6ace9vi4m869
Tags: 2013.1.g3-0ubuntu1
[ Yolanda Robla Mota ]
* d/control: Add BD on python-hp3parclient.
* d/patches: Drop patches related to disabling hp3parclient.

[ James Page ]
* d/control: Add Suggests: python-hp3parclient for python-cinder.
* d/control: Add BD on python-oslo-config.
* d/*: Wrapped and sorted.

[ Chuck Short ]
* New upstream release.
* debian/rules, debian/cinder-volumes.install: 
  - Fail if binaries are missing and install missing binaries.
* debian/patches/fix-ubuntu-tests.patch: Fix failing tests.
* debian/control: Add python-rtslib and python-mock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
 
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 Boolean, Column, DateTime
 
19
from sqlalchemy import MetaData, Integer, String, Table
 
20
 
 
21
from cinder.openstack.common import log as logging
 
22
 
 
23
LOG = logging.getLogger(__name__)
 
24
 
 
25
 
 
26
def upgrade(migrate_engine):
 
27
    meta = MetaData()
 
28
    meta.bind = migrate_engine
 
29
 
 
30
    # New table
 
31
    backups = Table(
 
32
        'backups', 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', String(36), primary_key=True, nullable=False),
 
38
        Column('volume_id', String(36), nullable=False),
 
39
        Column('user_id', String(length=255, convert_unicode=False,
 
40
                                 assert_unicode=None,
 
41
                                 unicode_error=None,
 
42
                                 _warn_on_bytestring=False)),
 
43
        Column('project_id', String(length=255, convert_unicode=False,
 
44
                                    assert_unicode=None,
 
45
                                    unicode_error=None,
 
46
                                    _warn_on_bytestring=False)),
 
47
        Column('host', String(length=255, convert_unicode=False,
 
48
                              assert_unicode=None,
 
49
                              unicode_error=None,
 
50
                              _warn_on_bytestring=False)),
 
51
        Column('availability_zone', String(length=255,
 
52
                                           convert_unicode=False,
 
53
                                           assert_unicode=None,
 
54
                                           unicode_error=None,
 
55
                                           _warn_on_bytestring=False)),
 
56
        Column('display_name', String(length=255, convert_unicode=False,
 
57
                                      assert_unicode=None,
 
58
                                      unicode_error=None,
 
59
                                      _warn_on_bytestring=False)),
 
60
        Column('display_description', String(length=255,
 
61
                                             convert_unicode=False,
 
62
                                             assert_unicode=None,
 
63
                                             unicode_error=None,
 
64
                                             _warn_on_bytestring=False)),
 
65
        Column('container', String(length=255, convert_unicode=False,
 
66
                                   assert_unicode=None,
 
67
                                   unicode_error=None,
 
68
                                   _warn_on_bytestring=False)),
 
69
        Column('status', String(length=255, convert_unicode=False,
 
70
                                assert_unicode=None,
 
71
                                unicode_error=None,
 
72
                                _warn_on_bytestring=False)),
 
73
        Column('fail_reason', String(length=255, convert_unicode=False,
 
74
                                     assert_unicode=None,
 
75
                                     unicode_error=None,
 
76
                                     _warn_on_bytestring=False)),
 
77
        Column('service_metadata', String(length=255, convert_unicode=False,
 
78
                                          assert_unicode=None,
 
79
                                          unicode_error=None,
 
80
                                          _warn_on_bytestring=False)),
 
81
        Column('service', String(length=255, convert_unicode=False,
 
82
                                 assert_unicode=None,
 
83
                                 unicode_error=None,
 
84
                                 _warn_on_bytestring=False)),
 
85
        Column('size', Integer()),
 
86
        Column('object_count', Integer()),
 
87
        mysql_engine='InnoDB'
 
88
    )
 
89
 
 
90
    try:
 
91
        backups.create()
 
92
    except Exception:
 
93
        LOG.error(_("Table |%s| not created!"), repr(backups))
 
94
        raise
 
95
 
 
96
 
 
97
def downgrade(migrate_engine):
 
98
    meta = MetaData()
 
99
    meta.bind = migrate_engine
 
100
 
 
101
    backups = Table('backups', meta, autoload=True)
 
102
    try:
 
103
        backups.drop()
 
104
    except Exception:
 
105
        LOG.error(_("backups table not dropped"))
 
106
        raise