details: http://www.bx.psu.edu/hg/galaxy/rev/b7857b33dbd8 changeset: 3080:b7857b33dbd8 user: Enis Afgan <afgane@gmail.com> date: Mon Nov 02 17:11:03 2009 -0500 description: Added machine image adding/deleting/viewing as admin action. diffstat: lib/galaxy/web/controllers/cloud.py | 30 ++++++++++++--- templates/admin/index.mako | 9 ++++ templates/cloud/list_images.mako | 64 ++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) diffs (138 lines): diff -r dabbf7210eb7 -r b7857b33dbd8 lib/galaxy/web/controllers/cloud.py --- a/lib/galaxy/web/controllers/cloud.py Mon Nov 02 14:23:37 2009 -0500 +++ b/lib/galaxy/web/controllers/cloud.py Mon Nov 02 17:11:03 2009 -0500 @@ -350,8 +350,8 @@ "<br />Note: you will be able to add more storage later", value='', error=vol_error ) ) @web.expose - @web.require_login( "add a cloud image" ) - #@web.require_admin + #@web.require_login( "add a cloud image" ) + @web.require_admin def addNewImage( self, trans, image_id='', manifest='', state=None ): error = None if image_id: @@ -373,14 +373,32 @@ trans.log_event( "New cloud image added: '%s'" % image.image_id ) trans.set_message( "Cloud image '%s' added." % image.image_id ) if state: - image.state= state - return self.list( trans ) - + image.state = state + images = trans.sa_session.query( model.CloudImage ).all() + return trans.fill_template( '/cloud/list_images.mako', images=images ) + return trans.show_form( web.FormBuilder( web.url_for(), "Add new cloud image", submit_text="Add" ) .add_text( "image_id", "Machine Image ID (AMI or EMI)", value='', error=error ) .add_text( "manifest", "Manifest", value='', error=error ) ) - + + @web.expose + @web.require_login( "use Galaxy cloud" ) + def listMachineImages( self, trans ): + images = trans.sa_session.query( model.CloudImage ).all() + return trans.fill_template( '/cloud/list_images.mako', images=images ) + + @web.expose + @web.require_admin + def deleteImage( self, trans, id=None ): + if not isinstance( id, int ): + id = trans.security.decode_id( id ) + + image = trans.sa_session.query( model.CloudImage ).get( id ) + image.delete() + image.flush() + return self.listMachineImages( trans ) + @web.expose @web.require_login( "use Galaxy cloud" ) def edit( self, trans, id, credName=None, accessKey=None, secretKey=None, edited=False ): diff -r dabbf7210eb7 -r b7857b33dbd8 templates/admin/index.mako --- a/templates/admin/index.mako Mon Nov 02 14:23:37 2009 -0500 +++ b/templates/admin/index.mako Mon Nov 02 17:11:03 2009 -0500 @@ -122,6 +122,15 @@ <div class="toolTitle"><a href="${h.url_for( controller='requests_admin', action='list')}" target="galaxy_main">Manage requests</a></div> </div> </div> + <div class="toolSectionTitle"> + <span>Cloud</span> + </div> + <div class="toolSectionBody"> + <div class="toolSectionBg"> + <div class="toolTitle"><a href="${h.url_for( controller='cloud', action='listMachineImages' )}" target="galaxy_main">List machine images</a></div> + <div class="toolTitle"><a href="${h.url_for( controller='cloud', action='addNewImage' )}" target="galaxy_main">Add machine image</a></div> + </div> + </div> </div> </div> </div> diff -r dabbf7210eb7 -r b7857b33dbd8 templates/cloud/list_images.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/cloud/list_images.mako Mon Nov 02 17:11:03 2009 -0500 @@ -0,0 +1,64 @@ +<%inherit file="/base.mako"/> + +<%def name="title()">Cloud home</%def> + +%if message: +<% + try: + messagetype + except: + messagetype = "done" +%> + +<p /> +<div class="${messagetype}message"> + ${message} +</div> +%endif + +%if images: + <h2>List of registered machine images:</h2> + + <table class="mange-table colored" border="0" cellspacing="0" cellpadding="0" width="100%"> + <colgroup width="2%"></colgroup> + <colgroup width="13%"></colgroup> + <colgroup width="70%"></colgroup> + <colgroup width="5%"></colgroup> + + <tr class="header"> + <th>#</th> + <th>Machime image ID</th> + <th>Manifest</th> + <th>Delete</th> + <th></th> + </tr> + %for i, image in enumerate( images ): + <tr> + <td>${i+1}</td> + <td> + %if image.image_id: + ${image.image_id} + %else: + N/A + %endif + </td> + <td> + %if image.manifest: + ${image.manifest} + %else: + N/A + %endif + </td> + <td><div align="center"> + <a confirm="Are you sure you want to delete machine image '${image.image_id}'?" + href="${h.url_for( controller='cloud', action='deleteImage', id=trans.security.encode_id(image.id) )}">x</a> + </div></td> + </tr> + %endfor + </table> +%endif + + + + +