[hg] galaxy 3107: Fixed table migration bug encountered with Pos...
details: http://www.bx.psu.edu/hg/galaxy/rev/5fbda2fdb3ca changeset: 3107:5fbda2fdb3ca user: Enis Afgan <afgane@gmail.com> date: Wed Nov 18 13:36:37 2009 -0500 description: Fixed table migration bug encountered with PostgreSQL. diffstat: lib/galaxy/cloud/__init__.py | 12 ++++++++++-- lib/galaxy/cloud/providers/ec2.py | 8 ++++++-- lib/galaxy/cloud/providers/eucalyptus.py | 14 +++++++++----- lib/galaxy/model/__init__.py | 1 - lib/galaxy/model/mapping.py | 6 +++--- lib/galaxy/model/migrate/versions/0026_cloud_tables.py | 4 ++-- templates/cloud/view_instance.mako | 6 ++++-- universe_wsgi.ini.sample | 12 ++++++------ 8 files changed, 40 insertions(+), 23 deletions(-) diffs (258 lines): diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/cloud/__init__.py --- a/lib/galaxy/cloud/__init__.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/cloud/__init__.py Wed Nov 18 13:36:37 2009 -0500 @@ -45,6 +45,14 @@ ERROR = "error" ) +store_status = Bunch( + WAITING = "waiting", + IN_USE = "in-use", + CREATING = "creating", + DELETED = 'deleted', + ERROR = "error" +) + snapshot_status = Bunch( SUBMITTED = 'submitted', PENDING = 'pending', @@ -413,7 +421,7 @@ be given in following format: 'vol-78943248' """ vol = self.sa_session.query( model.CloudStore ).filter( model.CloudStore.table.c.volume_id == vol_id ).first() - vol.i_id = instance_id + vol.inst.instance_id = instance_id self.sa_session.add( vol ) self.sa_session.flush() @@ -559,7 +567,7 @@ def get_mi_id( self, instance_id=0 ): uci = self.sa_session.query( model.UCI ).get( self.uci_id ) self.sa_session.refresh( uci ) - return uci.instance[instance_id].mi_id + return uci.instance[instance_id].image.image_id def get_public_dns( self, instance_id=0 ): uci = self.sa_session.query( model.UCI ).get( self.uci_id ) diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/cloud/providers/ec2.py --- a/lib/galaxy/cloud/providers/ec2.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/cloud/providers/ec2.py Wed Nov 18 13:36:37 2009 -0500 @@ -49,6 +49,7 @@ ) store_status = Bunch( + WAITING = "waiting", IN_USE = "in-use", CREATING = "creating", DELETED = 'deleted', @@ -441,6 +442,8 @@ s = reservation.instances[0].state uci_wrapper.change_state( s, i_id, s ) uci_wrapper.set_security_group_name( self.security_group, i_id=i_id ) + vol_id = uci_wrapper.get_store_volume_id( store_id=0 ) # TODO: Once more that one vol/UCI is allowed, update this! + uci_wrapper.set_store_status( vol_id, store_status.WAITING ) log.debug( "Instance of UCI '%s' started, current state: '%s'" % ( uci_wrapper.get_name(), uci_wrapper.get_uci_state() ) ) except boto.exception.EC2ResponseError, e: err = "EC2 response error when retrieving instance information for UCI '" + uci_wrapper.get_name() + "': " + str( e ) @@ -560,6 +563,7 @@ stores = self.sa_session.query( model.CloudStore ) \ .filter( or_( model.CloudStore.table.c.status==store_status.IN_USE, model.CloudStore.table.c.status==store_status.CREATING, + model.CloudStore.table.c.status==store_status.WAITING, model.CloudStore.table.c.status==None ) ) \ .all() for store in stores: @@ -717,8 +721,8 @@ store.status = vl[0].status self.sa_session.add( store ) self.sa_session.flush() - if store.i_id != vl[0].instance_id: - store.i_id = vl[0].instance_id + if store.inst.instance_id != vl[0].instance_id: + store.inst.instance_id = vl[0].instance_id self.sa_session.add( store ) self.sa_session.flush() if store.attach_time != vl[0].attach_time: diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/cloud/providers/eucalyptus.py --- a/lib/galaxy/cloud/providers/eucalyptus.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/cloud/providers/eucalyptus.py Wed Nov 18 13:36:37 2009 -0500 @@ -49,6 +49,7 @@ ) store_status = Bunch( + WAITING = "waiting", IN_USE = "in-use", CREATING = "creating", DELETED = 'deleted', @@ -428,6 +429,8 @@ uci_wrapper.set_instance_id( i_index, i_id ) s = reservation.instances[0].state uci_wrapper.change_state( s, i_id, s ) + vol_id = uci_wrapper.get_store_volume_id( store_id=0 ) # TODO: Once more that one vol/UCI is allowed, update this! + uci_wrapper.set_store_status( vol_id, store_status.WAITING ) log.debug( "Instance of UCI '%s' started, current state: '%s'" % ( uci_wrapper.get_name(), uci_wrapper.get_uci_state() ) ) except boto.exception.EC2ResponseError, e: err = "EC2 response error when retrieving instance information for UCI '" + uci_wrapper.get_name() + "': " + str( e ) @@ -497,7 +500,7 @@ ## log.debug ( 'Error detaching volume; still going to try and stop instance %s.' % dbInstances.instance_id ) # store.attach_time = None # store.device = None -# store.i_id = None +# store.inst.instance_id = None # store.status = volStat # log.debug ( '***** volume status: %s' % volStat ) # @@ -549,6 +552,7 @@ stores = self.sa_session.query( model.CloudStore ) \ .filter( or_( model.CloudStore.table.c.status==store_status.IN_USE, model.CloudStore.table.c.status==store_status.CREATING, + model.CloudStore.table.c.status==store_status.WAITING, model.CloudStore.table.c.status==None ) ) \ .all() for store in stores: @@ -691,7 +695,7 @@ # Update store status in local DB with info from cloud provider if len(vl) > 0: try: - if store.status != vl[0].status: + if store.status != vl[0].status and store.availability_zone != 'epc': # In case something failed during creation of UCI but actual storage volume was created and yet # UCI state remained as 'new', try to remedy this by updating UCI state here if ( store.status == None ) and ( store.volume_id != None ): @@ -714,8 +718,8 @@ store.status = vl[0].status self.sa_session.add( store ) self.sa_session.flush() - if store.i_id != vl[0].instance_id: - store.i_id = vl[0].instance_id + if store.inst.instance_id != vl[0].instance_id: + store.inst.instance_id = vl[0].instance_id self.sa_session.add( store ) self.sa_session.flush() if store.attach_time != vl[0].attach_time: @@ -981,7 +985,7 @@ # try: # volumes = conn.get_all_volumes( vols ) # for i, v in enumerate( volumes ): -# uci.store[i].i_id = v.instance_id +# uci.store[i].inst.instance_id = v.instance_id # uci.store[i].status = v.status # uci.store[i].device = v.device # uci.store[i].flush() diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/model/__init__.py Wed Nov 18 13:36:37 2009 -0500 @@ -1077,7 +1077,6 @@ def __init__( self ): self.id = None self.volume_id = None - self.i_id = None self.user = None self.size = None self.availability_zone = None diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/model/mapping.py Wed Nov 18 13:36:37 2009 -0500 @@ -429,7 +429,7 @@ Column( "type", TEXT ), Column( "reservation_id", TEXT ), Column( "instance_id", TEXT ), - Column( "mi_id", TEXT, ForeignKey( "cloud_image.image_id" ), index=True ), + Column( "mi_id", Integer, ForeignKey( "cloud_image.id" ), index=True ), Column( "state", TEXT ), Column( "error", TEXT ), Column( "public_dns", TEXT ), @@ -447,7 +447,7 @@ Column( "volume_id", TEXT ), Column( "size", Integer, nullable=False ), Column( "availability_zone", TEXT ), - Column( "i_id", TEXT, ForeignKey( "cloud_instance.instance_id" ) ), + Column( "inst_id", Integer, ForeignKey( "cloud_instance.id" ) ), Column( "status", TEXT ), Column( "device", TEXT ), Column( "space_consumed", Integer ), @@ -1133,7 +1133,7 @@ assign_mapper( context, CloudStore, CloudStore.table, properties=dict( user=relation( User ), - i=relation( CloudInstance ), + inst=relation( CloudInstance ), snapshot=relation( CloudSnapshot, backref="store" ) ) ) diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca lib/galaxy/model/migrate/versions/0026_cloud_tables.py --- a/lib/galaxy/model/migrate/versions/0026_cloud_tables.py Wed Nov 18 10:57:24 2009 -0500 +++ b/lib/galaxy/model/migrate/versions/0026_cloud_tables.py Wed Nov 18 13:36:37 2009 -0500 @@ -56,7 +56,7 @@ Column( "type", TEXT ), Column( "reservation_id", TEXT ), Column( "instance_id", TEXT ), - Column( "mi_id", TEXT, ForeignKey( "cloud_image.id" ), index=True ), + Column( "mi_id", Integer, ForeignKey( "cloud_image.id" ), index=True ), Column( "state", TEXT ), Column( "error", TEXT ), Column( "public_dns", TEXT ), @@ -74,7 +74,7 @@ Column( "volume_id", TEXT ), Column( "size", Integer, nullable=False ), Column( "availability_zone", TEXT ), - Column( "i_id", TEXT, ForeignKey( "cloud_instance.id" ) ), + Column( "inst_id", Integer, ForeignKey( "cloud_instance.id" ) ), Column( "status", TEXT ), Column( "device", TEXT ), Column( "space_consumed", Integer ), diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca templates/cloud/view_instance.mako --- a/templates/cloud/view_instance.mako Wed Nov 18 10:57:24 2009 -0500 +++ b/templates/cloud/view_instance.mako Wed Nov 18 13:36:37 2009 -0500 @@ -67,7 +67,7 @@ %endif <tr> <td> AMI: </td> - <td> ${liveInstance.mi_id} </td> + <td> ${liveInstance.image.image_id} </td> </tr> <tr> <td> State:</td> @@ -81,6 +81,7 @@ <td> Storage size:</td> <td> ${liveInstance.uci.total_size} </td> </tr> + %if liveInstance.public_dns != None and liveInstance.public_dns != '': <tr> <td> Public DNS:</td> <% @@ -88,7 +89,8 @@ %> <td> <a href="${lnk}" target="_blank">${liveInstance.public_dns}</a></td> </tr> - %if liveInstance.private_dns != None: + %endif + %if liveInstance.private_dns != None and liveInstance.private_dns != '': <tr> <td> Private DNS:</td> <td> ${liveInstance.private_dns}</td> diff -r f4c2bf76b2e2 -r 5fbda2fdb3ca universe_wsgi.ini.sample --- a/universe_wsgi.ini.sample Wed Nov 18 10:57:24 2009 -0500 +++ b/universe_wsgi.ini.sample Wed Nov 18 13:36:37 2009 -0500 @@ -31,15 +31,15 @@ paste.app_factory = galaxy.web.buildapp:app_factory # By default, Galaxy uses a SQLite database found here -database_file = database/universe.sqlite +#database_file = database/universe.sqlite # You may use a SQLAlchemy connection string to specify an external database # instead. PostgreSQL and MySQL are supported. -#database_connection = postgres:///galaxy -#database_engine_option_echo = true -#database_engine_option_echo_pool = true -#database_engine_option_pool_size = 10 -#database_engine_option_max_overflow = 20 +database_connection = postgres:///galaxy +database_engine_option_echo = true +database_engine_option_echo_pool = true +database_engine_option_pool_size = 10 +database_engine_option_max_overflow = 20 # If using MySQL, see: # http://rapd.wordpress.com/2008/03/02/sqlalchemy-sqlerror-operationalerror-20...
participants (1)
-
Greg Von Kuster