details: http://www.bx.psu.edu/hg/galaxy/rev/256889bc552f changeset: 3183:256889bc552f user: Enis Afgan <afgane@gmail.com> date: Thu Dec 17 08:25:31 2009 -0500 description: Removed the requirement for a user to select a storage volume zone during UCI registration by adding '(any)' option in the dropdown menu followed by automatic selection. diffstat: lib/galaxy/web/controllers/cloud.py | 23 +++++++++++++++++++---- templates/cloud/configure_uci.mako | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diffs (60 lines): diff -r add56c970e9c -r 256889bc552f lib/galaxy/web/controllers/cloud.py --- a/lib/galaxy/web/controllers/cloud.py Thu Dec 17 07:21:38 2009 -0500 +++ b/lib/galaxy/web/controllers/cloud.py Thu Dec 17 08:25:31 2009 -0500 @@ -198,8 +198,9 @@ # Capture user configured instance information uci = model.UCI() uci.name = instanceName - uci.credentials = trans.sa_session.query( model.CloudUserCredentials ) \ + creds = trans.sa_session.query( model.CloudUserCredentials ) \ .filter( model.CloudUserCredentials.table.c.name==credName ).first() + uci.credentials = creds uci.user= user uci.total_size = volSize # This is OK now because new instance is being created and only one storage volume can be created at UCI creation time uci.state = uci_states.NEW_UCI @@ -208,6 +209,18 @@ storage.user = user storage.uci = uci storage.size = volSize + # If '(any)' zone was selected, just choose the first one that's available + if zone == "(any)": + zones = None + conn = get_connection( trans, creds ) + if conn != None: + try: + zones = conn.get_all_zones() + if len( zones ) > 0: + zone = str( zones[0] ).split(':')[1] + except boto.exception.EC2ResponseError, e: + log.error( "Retrieving zones for credentials '%s' failed: %s" % ( storedCred.name, e ) ) + providersToZones[storedCred.name] = [ "Retrieving zones failed: " + str( e ) ] storage.availability_zone = zone storage.status = store_status.ADDING # Persist @@ -235,9 +248,11 @@ avail_zones = [] try: zones = conn.get_all_zones() - for z in zones: - z = str( z ).split(':')[1] - avail_zones.append( z ) + if len( zones ) > 0: + avail_zones.append( "(any)" ) + for z in zones: + z = str( z ).split(':')[1] + avail_zones.append( z ) providersToZones[storedCred.name] = avail_zones except boto.exception.EC2ResponseError, e: log.error( "Retrieving zones for credentials '%s' failed: %s" % ( storedCred.name, e ) ) diff -r add56c970e9c -r 256889bc552f templates/cloud/configure_uci.mako --- a/templates/cloud/configure_uci.mako Thu Dec 17 07:21:38 2009 -0500 +++ b/templates/cloud/configure_uci.mako Thu Dec 17 08:25:31 2009 -0500 @@ -97,7 +97,7 @@ cls += " form-row-error" %> <div class="${cls}"> - <label>Zone to create storage in:</label> + <label>Create storage in zone:</label> <div class="form-row-input"> <select id="zones" name="zone" style="width:40em"> </select>