[hg] galaxy 3050: Cloud credentials can now be deleted/renamed
details: http://www.bx.psu.edu/hg/galaxy/rev/6f32d42dab74 changeset: 3050:6f32d42dab74 user: Enis Afgan <afgane@gmail.com> date: Fri Aug 21 17:36:40 2009 -0400 description: Cloud credentials can now be deleted/renamed diffstat: lib/galaxy/model/__init__.py | 9 ---- lib/galaxy/web/controllers/cloud.py | 76 +++++++++++++++++++++++--------------- templates/cloud/configure_cloud.mako | 26 ++++++++----- 3 files changed, 62 insertions(+), 49 deletions(-) diffs (217 lines): diff -r 4b4259e46607 -r 6f32d42dab74 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py Fri Aug 21 15:15:30 2009 -0400 +++ b/lib/galaxy/model/__init__.py Fri Aug 21 17:36:40 2009 -0400 @@ -166,15 +166,6 @@ self.user = user self.group = group -class Credential( object ): - """ - Crediential stores user credential data for accessing cloud resources - """ - def __init__(self, name=None, accessKey=None, secretKey=None): - self.name = name or "Unnamed account" - self.accessKey = accesKey - self.secretKey = secretKey - class History( object ): def __init__( self, id=None, name=None, user=None ): self.id = id diff -r 4b4259e46607 -r 6f32d42dab74 lib/galaxy/web/controllers/cloud.py --- a/lib/galaxy/web/controllers/cloud.py Fri Aug 21 15:15:30 2009 -0400 +++ b/lib/galaxy/web/controllers/cloud.py Fri Aug 21 17:36:40 2009 -0400 @@ -46,6 +46,17 @@ workflows = workflows ) @web.expose + @web.require_login( "use Galaxy cloud" ) + def makeDefault( self, trans ): + """ + Set current credentials as default to be used for submitting jobs + """ + awsCredentials = trans.sa_session.query ( model.StoredUserCredentials ).all() + + return trans.fill_template( "cloud/configure_cloud.mako", + awsCredentials = awsCredentials ) + + @web.expose @web.require_login( "use Galaxy workflows" ) def list_for_run( self, trans ): """ @@ -146,20 +157,20 @@ session.flush() # Redirect to load galaxy frames. return trans.response.send_redirect( url_for( controller='workflow' ) ) - + @web.expose - @web.require_login( "use Galaxy workflows" ) + @web.require_login( "use Galaxy cloud" ) def rename( self, trans, id, new_name=None ): - stored = get_stored_workflow( trans, id ) + stored = get_stored_credentials( trans, id ) if new_name is not None: stored.name = new_name trans.sa_session.flush() - trans.set_message( "Workflow renamed to '%s'." % new_name ) + trans.set_message( "Credentials renamed to '%s'." % new_name ) return self.list( trans ) else: - return form( url_for( id=trans.security.encode_id(stored.id) ), "Rename workflow", submit_text="Rename" ) \ - .add_text( "new_name", "Workflow Name", value=stored.name ) - + return form( url_for( id=trans.security.encode_id(stored.id) ), "Rename credentials", submit_text="Rename" ) \ + .add_text( "new_name", "Credentials Name", value=stored.name ) + @web.expose @web.require_login( "use Galaxy workflows" ) def clone( self, trans, id ): @@ -226,23 +237,23 @@ awsCredentials = trans.sa_session.query ( model.StoredUserCredentials ).all() log.debug( "in add" ) log.debug( user ) - log.debug( stored_credentials.name ) + log.debug( credentials.name ) log.debug( awsCredentials ) """ if account_name is not None: # Create new user stored credentials - stored_credentials = model.StoredUserCredentials() - stored_credentials.name = account_name - stored_credentials.user = user - stored_credentials.access_key = "access key" - stored_credentials.secret_key = "secret key" + credentials = model.StoredUserCredentials() + credentials.name = account_name + credentials.user = user + credentials.access_key = "access key" + credentials.secret_key = "secret key" # Persist session = trans.sa_session - session.save_or_update( stored_credentials ) + session.save_or_update( credentials ) session.flush() # Display the management page - trans.set_message( "Credential '%s' created" % stored_credentials.name ) + trans.set_message( "Credential '%s' created" % credentials.name ) return self.list( trans ) """ @@ -264,21 +275,26 @@ return self.list( trans ) """ else: - return form( url_for(), "Add AWS credentials", submit_text="Add" ) \ + return trans.fill_template("cloud/credentials.mako") + """ + form( url_for(), "Add AWS credentials", submit_text="Add" ) \ .add_text( "account_name", "Account Name", value="Unnamed credentials" ) - + .add_text( "access_key", "Access Key", value="" ) + .add_text( "secret_key", "Secret Key", value="" ) + """ @web.expose def delete( self, trans, id=None ): """ - Mark a workflow as deleted + Delete credentials """ - # Load workflow from database - stored = get_stored_workflow( trans, id ) - # Marke as deleted and save - stored.deleted = True + # Load credentials from database + stored = get_stored_credentials( trans, id ) + # Delete and save + sess = trans.sa_session + sess.delete( stored ) stored.flush() # Display the management page - trans.set_message( "Workflow '%s' deleted" % stored.name ) + trans.set_message( "Credentials '%s' deleted." % stored.name ) return self.list( trans ) @web.expose @@ -723,21 +739,21 @@ ## ---- Utility methods ------------------------------------------------------- -def get_stored_workflow( trans, id, check_ownership=True ): +def get_stored_credentials( trans, id, check_ownership=True ): """ - Get a StoredWorkflow from the database by id, verifying ownership. + Get a StoredUserCredntials from the database by id, verifying ownership. """ - # Load workflow from database + # Load credentials from database id = trans.security.decode_id( id ) - stored = trans.sa_session.query( model.StoredWorkflow ).get( id ) + stored = trans.sa_session.query( model.StoredUserCredentials ).get( id ) if not stored: - error( "Workflow not found" ) + error( "Credentials not found" ) # Verify ownership user = trans.get_user() if not user: - error( "Must be logged in to use workflows" ) + error( "Must be logged in to use the cloud." ) if check_ownership and not( stored.user == user ): - error( "Workflow is not owned by current user" ) + error( "Credentials are not owned by current user." ) # Looks good return stored diff -r 4b4259e46607 -r 6f32d42dab74 templates/cloud/configure_cloud.mako --- a/templates/cloud/configure_cloud.mako Fri Aug 21 15:15:30 2009 -0400 +++ b/templates/cloud/configure_cloud.mako Fri Aug 21 17:36:40 2009 -0400 @@ -1,6 +1,6 @@ <%inherit file="/base.mako"/> -<%def name="title()">Workflow home</%def> +<%def name="title()">Cloud home</%def> %if message: <% @@ -18,10 +18,19 @@ <h2>Galaxy in the clouds</h2> %if awsCredentials: + <ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( action='add' )}"> + <img src="${h.url_for('/static/images/silk/add.png')}" /> + <span>Add AWS credentials</span> + </a> + </li> + </ul> + <table class="mange-table colored" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr class="header"> - <th>Name</th> - <th># of Steps</th> + <th>Credentials Name</th> + <th>Default</th> ## <th>Last Updated</th> <th></th> </tr> @@ -32,15 +41,12 @@ <a id="wf-${i}-popup" class="popup-arrow" style="display: none;">▼</a> </td> ## Comment <td>${len(workflow.latest_workflow.steps)}</td> - ## Comment <td>${str(workflow.update_time)[:19]}</td> + ##<td>${str(awsCredentials.update_time)[:19]}</td> <td> <div popupmenu="wf-${i}-popup"> - ##<a class="action-button" href="${h.url_for( action='editor', id=trans.security.encode_id(workflow.id) )}" target="_parent">Edit</a> - ##<a class="action-button" href="${h.url_for( controller='root', action='index', workflow_id=trans.security.encode_id(workflow.id) )}" target="_parent">Run</a> - ##<a class="action-button" href="${h.url_for( action='clone', id=trans.security.encode_id(workflow.id) )}">Clone</a> - ##<a class="action-button" href="${h.url_for( action='rename', id=trans.security.encode_id(workflow.id) )}">Rename</a> - ##<a class="action-button" href="${h.url_for( action='sharing', id=trans.security.encode_id(workflow.id) )}">Sharing</a> - ##<a class="action-button" confirm="Are you sure you want to delete workflow '${workflow.name}'?" href="${h.url_for( action='delete', id=trans.security.encode_id(workflow.id) )}">Delete</a> + <a class="action-button" href="${h.url_for( action='makeDefault', id=trans.security.encode_id(awsCredential.id) )}" target="_parent">Made default</a> + <a class="action-button" href="${h.url_for( action='rename', id=trans.security.encode_id(awsCredential.id) )}">Rename</a> + <a class="action-button" confirm="Are you sure you want to delete workflow '${awsCredential.name}'?" href="${h.url_for( action='delete', id=trans.security.encode_id(awsCredential.id) )}">Delete</a> </div> </td> </tr>
participants (1)
-
Greg Von Kuster