AppController/djinn.rb
# Upload a Google App Engine application into this AppScale deployment.
#
# Args:
#   archived_file: A String, with the path to the compressed file containing
#     the app.
#   file_suffix: A String indicating what suffix the file should have.
#   email: A String with the email address of the user that will own this app.
#   secret: A String with the shared key for authentication.
# Returns:
#   A JSON-dumped Hash with fields indicating if the upload process began
#   successfully, and a reservation ID that can be used with
#   get_app_upload_status to see if the app has successfully uploaded or not.
Upload a Google App Engine application into this AppScale deployment.
Args:
archived_file: A String, with the path to the compressed file containing
the app.
file_suffix: A String indicating what suffix the file should have.
email: A String with the email address of the user that will own this app.
secret: A String with the shared key for authentication.
Returns:
A JSON-dumped Hash with fields indicating if the upload process began
successfully, and a reservation ID that can be used with
get_app_upload_status to see if the app has successfully uploaded or not.
Upload a Google App Engine application into this AppScale deployment . Args : archived_file : A String with the path to the compressed file containing the app . file_suffix : A String indicating what suffix the file should have . email : A String with the email address of the user that will own this app . secret : A String with the shared key for authentication . Returns : A JSON - dumped Hash with fields indicating if the upload process began successfully and a reservation ID that can be used with get_app_upload_status to see if the app has successfully uploaded or not .
def upload_app(archived_file, file_suffix, email, secret)
    return BAD_SECRET_MSG unless valid_secret?(secret)
    unless my_node.is_shadow?
      Djinn.log_debug("Sending upload_app call to shadow.")
      acc = AppControllerClient.new(get_shadow.private_ip, @@secret)
      begin
        remote_file = [archived_file, file_suffix].join('.')
        HelperFunctions.scp_file(archived_file, remote_file,
                                 get_shadow.private_ip, get_shadow.ssh_key)
        return acc.upload_app(remote_file, file_suffix, email)
      rescue FailedNodeException => except
        Djinn.log_warn("Failed to forward upload_app call to shadow (#{get_shadow}).")
        return NOT_READY
      end
    end
    reservation_id = HelperFunctions.get_random_alphanumeric()
    @app_upload_reservations[reservation_id] = {'status' => 'starting'}
    Djinn.log_debug(
      "Received a request to upload app at #{archived_file}, with suffix " +
      "#{file_suffix}, with admin user #{email}.")
    Thread.new {
      unless archived_file.match(/#{file_suffix}$/)
        new_location = [archived_file, file_suffix].join('.')
        Djinn.log_debug("Copying #{archived_file} to #{new_location}")
        FileUtils.copy(archived_file, new_location)
        archived_file = new_location
      end
      Djinn.log_debug("Uploading file at location #{archived_file}")
      keyname = @options['keyname']
      command = "#{UPLOAD_APP_SCRIPT} --file '#{archived_file}' " +
        "--email #{email} --keyname #{keyname} 2>&1"
      output = Djinn.log_run(command)
      if output.include?("Your app can be reached at the following URL")
        result = "true"
      else
        result = output
      end
      @app_upload_reservations[reservation_id]['status'] = result
      File.delete(archived_file)
    }
    return JSON.dump({
      'reservation_id' => reservation_id,
      'status' => 'starting'
    })
  end
def upload_app ( archived_file , file_suffix , email , secret ) return BAD_SECRET_MSG unless valid_secret? ( secret ) unless my_node . is_shadow? Djinn . log_debug ( "Sending upload_app call to shadow." ) acc = AppControllerClient . new ( get_shadow . private_ip , @@secret ) begin remote_file = [ archived_file , file_suffix ] . join ( '.' ) HelperFunctions . scp_file ( archived_file , remote_file , get_shadow . private_ip , get_shadow . ssh_key ) return acc . upload_app ( remote_file , file_suffix , email ) rescue FailedNodeException => except Djinn . log_warn ( "Failed to forward upload_app call to shadow (#{get_shadow})." ) return NOT_READY end end reservation_id = HelperFunctions . get_random_alphanumeric ( ) @app_upload_reservations [ reservation_id ] = { 'status' => 'starting' } Djinn . log_debug ( "Received a request to upload app at #{archived_file}, with suffix " + "#{file_suffix}, with admin user #{email}." ) Thread . new { unless archived_file . match ( / #{ file_suffix } $ / ) new_location = [ archived_file , file_suffix ] . join ( '.' ) Djinn . log_debug ( "Copying #{archived_file} to #{new_location}" ) FileUtils . copy ( archived_file , new_location ) archived_file = new_location end Djinn . log_debug ( "Uploading file at location #{archived_file}" ) keyname = @options [ 'keyname' ] command = "#{UPLOAD_APP_SCRIPT} --file '#{archived_file}' " + "--email #{email} --keyname #{keyname} 2>&1" output = Djinn . log_run ( command ) if output . include? ( "Your app can be reached at the following URL" ) result = "true" else result = output end @app_upload_reservations [ reservation_id ] [ 'status' ] = result File . delete ( archived_file ) } return JSON . dump ( { 'reservation_id' => reservation_id , 'status' => 'starting' } ) end
Upload a Google App Engine application into this AppScale deployment.
Upload a Google App Engine application into this AppScale deployment .
# If the dashboard is on the same node as the shadow, the archive needs # to be copied to a location that includes the suffix.
archived_file
<not_specific>
file_suffix
<not_specific>
email
<not_specific>
secret
<not_specific>