root/galaxy-central/lib/galaxy/model/migrate/versions/0026_cloud_tables.py

リビジョン 2, 6.0 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1from sqlalchemy import *
2from migrate import *
3
4import datetime
5now = datetime.datetime.utcnow
6
7# Need our custom types, but don't import anything else from model
8from galaxy.model.custom_types import *
9
10import logging
11log = logging.getLogger( __name__ )
12
13metadata = MetaData( migrate_engine )
14
15def display_migration_details():
16    print
17    print "========================================"
18    print "This script adds tables needed for Galaxy cloud functionality."
19    print "========================================"
20   
21CloudImage_table = Table( "cloud_image", metadata,
22    Column( "id", Integer, primary_key=True ),
23    Column( "create_time", DateTime, default=now ),
24    Column( "update_time", DateTime, default=now, onupdate=now ),
25    Column( "provider_type", TEXT ),
26    Column( "image_id", TEXT, nullable=False ),
27    Column( "manifest", TEXT ),
28    Column( "state", TEXT ),
29    Column( "architecture", TEXT ),
30    Column( "deleted", Boolean, default=False ) )
31
32""" UserConfiguredInstance (UCI) table """
33UCI_table = Table( "cloud_uci", metadata,
34    Column( "id", Integer, primary_key=True ),
35    Column( "create_time", DateTime, default=now ),
36    Column( "update_time", DateTime, default=now, onupdate=now ),
37    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
38    Column( "credentials_id", Integer, ForeignKey( "cloud_user_credentials.id" ), index=True ),
39    Column( "key_pair_name", TEXT ),
40    Column( "key_pair_material", TEXT ),
41    Column( "name", TEXT ),
42    Column( "state", TEXT ),
43    Column( "error", TEXT ),
44    Column( "total_size", Integer ),
45    Column( "launch_time", DateTime ),
46    Column( "deleted", Boolean, default=False ) )
47
48CloudInstance_table = Table( "cloud_instance", metadata,
49    Column( "id", Integer, primary_key=True ),
50    Column( "create_time", DateTime, default=now ),
51    Column( "update_time", DateTime, default=now, onupdate=now ),
52    Column( "launch_time", DateTime ),
53    Column( "stop_time", DateTime ),
54    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
55    Column( "uci_id", Integer, ForeignKey( "cloud_uci.id" ), index=True ),
56    Column( "type", TEXT ),
57    Column( "reservation_id", TEXT ),
58    Column( "instance_id", TEXT ),
59    Column( "mi_id", Integer, ForeignKey( "cloud_image.id" ), index=True ),
60    Column( "state", TEXT ),
61    Column( "error", TEXT ),
62    Column( "public_dns", TEXT ),
63    Column( "private_dns", TEXT ),
64    Column( "security_group", TEXT ),
65    Column( "availability_zone", TEXT ) )
66
67CloudStore_table = Table( "cloud_store", metadata,
68    Column( "id", Integer, primary_key=True ),
69    Column( "create_time", DateTime, default=now ),
70    Column( "update_time", DateTime, default=now, onupdate=now ),
71    Column( "attach_time", DateTime ),
72    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
73    Column( "uci_id", Integer, ForeignKey( "cloud_uci.id" ), index=True, nullable=False ),
74    Column( "volume_id", TEXT ),
75    Column( "size", Integer, nullable=False ),
76    Column( "availability_zone", TEXT ),
77    Column( "inst_id", Integer, ForeignKey( "cloud_instance.id" ) ),
78    Column( "status", TEXT ),
79    Column( "device", TEXT ),
80    Column( "space_consumed", Integer ),
81    Column( "error", TEXT ),
82    Column( "deleted", Boolean, default=False ) )
83
84CloudSnapshot_table = Table( "cloud_snapshot", metadata,
85    Column( "id", Integer, primary_key=True ),
86    Column( "create_time", DateTime, default=now ),
87    Column( "update_time", DateTime, default=now, onupdate=now ),
88    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
89    Column( "uci_id", Integer, ForeignKey( "cloud_uci.id" ), index=True ),
90    Column( "store_id", Integer, ForeignKey( "cloud_store.id" ), index=True, nullable=False ),
91    Column( "snapshot_id", TEXT ),
92    Column( "status", TEXT ),
93    Column( "description", TEXT ),
94    Column( "error", TEXT ),
95    Column( "deleted", Boolean, default=False ) )
96
97CloudUserCredentials_table = Table( "cloud_user_credentials", metadata,
98    Column( "id", Integer, primary_key=True ),
99    Column( "create_time", DateTime, default=now ),
100    Column( "update_time", DateTime, default=now, onupdate=now ),
101    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
102    Column( "provider_id", Integer, ForeignKey( "cloud_provider.id" ), index=True, nullable=False ),
103    Column( "name", TEXT ),
104    Column( "access_key", TEXT ),
105    Column( "secret_key", TEXT ),
106    Column( "deleted", Boolean, default=False ) )
107
108CloudProvider_table = Table( "cloud_provider", metadata,
109    Column( "id", Integer, primary_key=True ),
110    Column( "create_time", DateTime, default=now ),
111    Column( "update_time", DateTime, default=now, onupdate=now ),
112    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
113    Column( "type", TEXT, nullable=False ),
114    Column( "name", TEXT ),
115    Column( "region_connection", TEXT ),
116    Column( "region_name", TEXT ),
117    Column( "region_endpoint", TEXT ),
118    Column( "is_secure", Boolean ),
119    Column( "host", TEXT ),
120    Column( "port", Integer ),
121    Column( "proxy", TEXT ),
122    Column( "proxy_port", TEXT ),
123    Column( "proxy_user", TEXT ),
124    Column( "proxy_pass", TEXT ),
125    Column( "debug", Integer ),
126    Column( "https_connection_factory", TEXT ),
127    Column( "path", TEXT ),
128    Column( "deleted", Boolean, default=False ) )
129
130def upgrade():
131    display_migration_details()
132    # Load existing tables
133    metadata.reflect()
134   
135    CloudProvider_table.create()
136    CloudUserCredentials_table.create()
137
138    CloudImage_table.create()
139    UCI_table.create()
140
141    CloudInstance_table.create()
142    CloudStore_table.create()
143    CloudSnapshot_table.create()
144   
145def downgrade():
146    metadata.reflect()
147   
148    CloudInstance_table.drop()
149    CloudSnapshot_table.drop()
150    CloudStore_table.drop()
151
152    UCI_table.drop()
153    CloudImage_table.drop()
154
155    CloudUserCredentials_table.drop()
156    CloudProvider_table.drop()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。