[hg] galaxy 3083: Bug fixes regarding registration of new provid...
details: http://www.bx.psu.edu/hg/galaxy/rev/28252033d66a changeset: 3083:28252033d66a user: Enis Afgan <afgane@gmail.com> date: Thu Nov 05 11:27:00 2009 -0500 description: Bug fixes regarding registration of new providers and creation of new UCIs. diffstat: lib/galaxy/cloud/providers/ec2.py | 73 +++++++++--------- lib/galaxy/cloud/providers/eucalyptus.py | 76 +++++++++--------- lib/galaxy/model/migrate/versions/0014_cloud_tables.py | 53 +++++++----- lib/galaxy/web/controllers/cloud.py | 13 ++- templates/cloud/list_images.mako | 4 + 5 files changed, 118 insertions(+), 101 deletions(-) diffs (340 lines): diff -r 70ae74578254 -r 28252033d66a lib/galaxy/cloud/providers/ec2.py --- a/lib/galaxy/cloud/providers/ec2.py Wed Nov 04 17:19:18 2009 -0500 +++ b/lib/galaxy/cloud/providers/ec2.py Thu Nov 05 11:27:00 2009 -0500 @@ -402,19 +402,19 @@ model.CloudStore.c.status==store_states.CREATING, model.CloudStore.c.status==None ) ).all() for store in stores: - if self.type == store.uci.credentials.provider.type and store.volume_id != None: - log.debug( "[%s] Running general status update on store '%s'" % ( store.uci.credentials.provider.type, store.volume_id ) ) + if self.type == store.uci.credentials.provider.type: # and store.volume_id != None: + log.debug( "[%s] Running general status update on store with local database ID: '%s'" % ( store.uci.credentials.provider.type, store.id ) ) self.updateStore( store ) - else: - log.error( "[%s] There exists an entry for UCI (%s) storage volume without an ID. Storage volume might have been created with " - "cloud provider though. Manual check is recommended." % ( store.uci.credentials.provider.type, store.uci.name ) ) - store.uci.error = "There exists an entry in local database for a storage volume without an ID. Storage volume might have been created " \ - "with cloud provider though. Manual check is recommended. After understanding what happened, local database etry for given " \ - "storage volume should be updated." - store.status = store_states.ERROR - store.uci.state = uci_states.ERROR - store.uci.flush() - store.flush() +# else: +# log.error( "[%s] There exists an entry for UCI (%s) storage volume without an ID. Storage volume might have been created with " +# "cloud provider though. Manual check is recommended." % ( store.uci.credentials.provider.type, store.uci.name ) ) +# store.uci.error = "There exists an entry in local database for a storage volume without an ID. Storage volume might have been created " \ +# "with cloud provider though. Manual check is recommended. After understanding what happened, local database entry for given " \ +# "storage volume should be updated." +# store.status = store_states.ERROR +# store.uci.state = uci_states.ERROR +# store.uci.flush() +# store.flush() # Attempt at updating any zombie UCIs (i.e., instances that have been in SUBMITTED state for longer than expected - see below for exact time) zombies = model.UCI.filter_by( state=uci_states.SUBMITTED ).all() @@ -509,30 +509,31 @@ return None # Update store status in local DB with info from cloud provider - try: - if store.status != vl[0].status: - # 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 ): - uci.state = vl[0].status - uci.flush() - - store.status = vl[0].status - store.flush() - if store.i_id != vl[0].instance_id: - store.i_id = vl[0].instance_id - store.flush() - if store.attach_time != vl[0].attach_time: - store.attach_time = vl[0].attach_time - store.flush() - if store.device != vl[0].device: - store.device = vl[0].device - store.flush() - except boto.exception.EC2ResponseError, e: - log.error( "Updating status of volume(s) from cloud for UCI '%s' failed: " % ( uci.name, str(e) ) ) - uci.error( "Updating volume status from cloud failed: " + str(e) ) - uci.state( uci_states.ERROR ) - return None + if len(vl) > 0: + try: + if store.status != vl[0].status: + # 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 ): + uci.state = vl[0].status + uci.flush() + + store.status = vl[0].status + store.flush() + if store.i_id != vl[0].instance_id: + store.i_id = vl[0].instance_id + store.flush() + if store.attach_time != vl[0].attach_time: + store.attach_time = vl[0].attach_time + store.flush() + if store.device != vl[0].device: + store.device = vl[0].device + store.flush() + except boto.exception.EC2ResponseError, e: + log.error( "Updating status of volume(s) from cloud for UCI '%s' failed: " % ( uci.name, str(e) ) ) + uci.error( "Updating volume status from cloud failed: " + str(e) ) + uci.state( uci_states.ERROR ) + return None def processZombie( self, inst ): """ diff -r 70ae74578254 -r 28252033d66a lib/galaxy/cloud/providers/eucalyptus.py --- a/lib/galaxy/cloud/providers/eucalyptus.py Wed Nov 04 17:19:18 2009 -0500 +++ b/lib/galaxy/cloud/providers/eucalyptus.py Thu Nov 05 11:27:00 2009 -0500 @@ -368,19 +368,19 @@ model.CloudStore.c.status==store_states.CREATING, model.CloudStore.c.status==None ) ).all() for store in stores: - if self.type == store.uci.credentials.provider.type and store.volume_id != None: - log.debug( "[%s] Running general status update on store '%s'" % ( store.uci.credentials.provider.type, store.volume_id ) ) + if self.type == store.uci.credentials.provider.type: # and store.volume_id != None: + log.debug( "[%s] Running general status update on store with local database ID: '%s'" % ( store.uci.credentials.provider.type, store.id ) ) self.updateStore( store ) - else: - log.error( "[%s] There exists an entry for UCI (%s) storage volume without an ID. Storage volume might have been created with " - "cloud provider though. Manual check is recommended." % ( store.uci.credentials.provider.type, store.uci.name ) ) - store.uci.error = "There exists an entry in local database for a storage volume without an ID. Storage volume might have been created " \ - "with cloud provider though. Manual check is recommended. After understanding what happened, local database etry for given " \ - "storage volume should be updated." - store.status = store_states.ERROR - store.uci.state = uci_states.ERROR - store.uci.flush() - store.flush() +# else: +# log.error( "[%s] There exists an entry for UCI (%s) storage volume without an ID. Storage volume might have been created with " +# "cloud provider though. Manual check is recommended." % ( store.uci.credentials.provider.type, store.uci.name ) ) +# store.uci.error = "There exists an entry in local database for a storage volume without an ID. Storage volume might have been created " \ +# "with cloud provider though. Manual check is recommended. After understanding what happened, local database entry for given " \ +# "storage volume should be updated." +# store.status = store_states.ERROR +# store.uci.state = uci_states.ERROR +# store.uci.flush() +# store.flush() # Attempt at updating any zombie UCIs (i.e., instances that have been in SUBMITTED state for longer than expected - see below for exact time) zombies = model.UCI.filter_by( state=uci_states.SUBMITTED ).all() @@ -465,39 +465,41 @@ conn = self.get_connection_from_uci( uci ) try: - log.debug( "vol id: " % store.volume_id ) vl = conn.get_all_volumes( [store.volume_id] ) except boto.exception.EC2ResponseError, e: log.error( "Retrieving volume(s) from cloud for UCI '%s' failed: " % ( uci.name, str(e) ) ) uci.error( "Retrieving volume(s) from cloud failed: " + str(e) ) uci.state( uci_states.ERROR ) + uci.flush() return None # Update store status in local DB with info from cloud provider - try: - if store.status != vl[0].status: - # 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 ): - uci.state = vl[0].status - uci.flush() - - store.status = vl[0].status - store.flush() - if store.i_id != vl[0].instance_id: - store.i_id = vl[0].instance_id - store.flush() - if store.attach_time != vl[0].attach_time: - store.attach_time = vl[0].attach_time - store.flush() - if store.device != vl[0].device: - store.device = vl[0].device - store.flush() - except boto.exception.EC2ResponseError, e: - log.error( "Updating status of volume(s) from cloud for UCI '%s' failed: " % ( uci.name, str(e) ) ) - uci.error( "Updating volume status from cloud failed: " + str(e) ) - uci.state( uci_states.ERROR ) - return None + if len(vl) > 0: + try: + if store.status != vl[0].status: + # 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 ): + uci.state = vl[0].status + uci.flush() + + store.status = vl[0].status + store.flush() + if store.i_id != vl[0].instance_id: + store.i_id = vl[0].instance_id + store.flush() + if store.attach_time != vl[0].attach_time: + store.attach_time = vl[0].attach_time + store.flush() + if store.device != vl[0].device: + store.device = vl[0].device + store.flush() + except boto.exception.EC2ResponseError, e: + log.error( "Updating status of volume(s) from cloud for UCI '%s' failed: " % ( uci.name, str(e) ) ) + uci.error( "Updating volume status from cloud failed: " + str(e) ) + uci.state( uci_states.ERROR ) + uci.flush() + return None def processZombie( self, inst ): """ diff -r 70ae74578254 -r 28252033d66a lib/galaxy/model/migrate/versions/0014_cloud_tables.py --- a/lib/galaxy/model/migrate/versions/0014_cloud_tables.py Wed Nov 04 17:19:18 2009 -0500 +++ b/lib/galaxy/model/migrate/versions/0014_cloud_tables.py Thu Nov 05 11:27:00 2009 -0500 @@ -101,65 +101,72 @@ def upgrade(): metadata.reflect() + log.debug( "Creating cloud_image table." ) try: CloudImage_table.create() except Exception, e: log.debug( "Creating cloud_image table failed. Table probably exists already." ) + log.debug( "Creating cloud_uci table." ) try: UCI_table.create() except Exception, e: log.debug( "Creating UCI table failed. Table probably exists already." ) try: - CloudInstance_table.create() - except Exception, e: - log.debug( "Creating cloud_instance table failed. Table probably exists already." ) - try: - CloudStore_table.create() - except Exception: - log.debug( "Creating cloud_store table failed. Table probably exists already." ) - try: CloudUserCredentials_table.create() except Exception, e: log.debug( "Creating cloud_image table failed. Table probably exists already." ) + log.debug( "Creating cloud_provider table." ) try: CloudProvider_table.create() except Exception, e: log.debug( "Creating cloud_provider table failed. Table probably exists already." ) + log.debug( "Creating cloud_instance table." ) + #try: + CloudInstance_table.create() + #except Exception, e: + # log.debug( "Creating cloud_instance table failed. Table probably exists already." ) + #log.debug( "Creating cloud_store table." ) + #try: + CloudStore_table.create() + #except Exception: + # log.debug( "Creating cloud_store table failed. Table probably exists already." ) def downgrade(): metadata.reflect() try: - log.debug( "Would drop cloud_image table." ) -# CloudImage_table.drop() #Enable before release + #log.debug( "Would drop cloud_image table." ) + CloudImage_table.drop() #Enable before release except Exception, e: log.debug( "Dropping cloud_image table failed: %s" % str( e ) ) - try: - log.debug( "Would drop cloud_instance table." ) -# CloudInstance_table.drop() - except Exception, e: - log.debug( "Dropping cloud_instance table failed: %s" % str( e ) ) +# try: +# #log.debug( "Would drop cloud_instance table." ) +# print "inst" + CloudInstance_table.drop() +# except Exception, e: +# log.debug( "Dropping cloud_instance table failed: %s" % str( e ) ) - try: - log.debug( "Would drop cloud_store table." ) -# CloudStore_table.drop() - except Exception, e: - log.debug( "Dropping cloud_store table failed: %s" % str( e ) ) +# try: +# #log.debug( "Would drop cloud_store table." ) +# print "store" + CloudStore_table.drop() +# except Exception, e: +# log.debug( "Dropping cloud_store table failed: %s" % str( e ) ) try: log.debug( "Would drop cloud_user_credentials table." ) -# CloudUserCredentials_table.drop() #Enable before putting final version + CloudUserCredentials_table.drop() #Enable before putting final version except Exception, e: log.debug( "Dropping cloud_user_credentials table failed: %s" % str( e ) ) try: log.debug( "Would drop UCI table." ) -# UCI_table.drop() + UCI_table.drop() except Exception, e: log.debug( "Dropping UCI table failed: %s" % str( e ) ) try: -# log.debug( "Would drop cloud_provider table." ) + log.debug( "Would drop cloud_provider table." ) CloudProvider_table.drop() except Exception, e: log.debug( "Dropping cloud_provider table failed: %s" % str( e ) ) diff -r 70ae74578254 -r 28252033d66a lib/galaxy/web/controllers/cloud.py --- a/lib/galaxy/web/controllers/cloud.py Wed Nov 04 17:19:18 2009 -0500 +++ b/lib/galaxy/web/controllers/cloud.py Thu Nov 05 11:27:00 2009 -0500 @@ -626,12 +626,13 @@ proxy_user='', proxy_pass='', debug='', https_connection_factory='', path='' ): user = trans.get_user() error = {} - try: - is_secure = int(is_secure) - except ValueError: - pass if region_name or region_endpoint or name or is_secure or port or proxy or debug or path: + try: + is_secure = int(is_secure) + except ValueError: + error['is_secure_error'] = "Field 'is secure' can only take on a value '0' or '1'" + if trans.app.model.CloudProvider \ .filter_by (user=user, name=name) \ .first(): @@ -657,9 +658,11 @@ else: provider.region_endpoint = None - if is_secure=='0': + if is_secure==0: + log.debug("is_secure is false") provider.is_secure = False else: + log.debug("is_secure is true") provider.is_secure = True if host: diff -r 70ae74578254 -r 28252033d66a templates/cloud/list_images.mako --- a/templates/cloud/list_images.mako Wed Nov 04 17:19:18 2009 -0500 +++ b/templates/cloud/list_images.mako Thu Nov 05 11:27:00 2009 -0500 @@ -60,6 +60,10 @@ </tr> %endfor </table> +%else: + <h3>There are no registered machine images.</h3><br /> + <a href="${h.url_for( controller='cloud', action='addNewImage' )}" target="galaxy_main">Add machine image now?</a> + %endif
participants (1)
-
Greg Von Kuster