1
# Programmer: Chris Bunch
4
require 'datastore_repo'
6
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "Neptune")
7
require 'task_engine_google_app_engine'
10
# An implementation of the Repository app that assumes it is running
11
# within App Engine. Since App Engine is a remote service, we have to check
12
# to see if it's running or not, and upload it when it's not running.
13
class DatastoreRepoOnAppEngine < DatastoreRepo
16
# The host (IP, colon, port) that the Repo app is hosted at.
20
# The name of this datastore, which we call AppDB since Neptune jobs
21
# basically use it as an interface to AppScale's database agnostic
23
NAME = "repo-appengine"
26
# Creates a new connection to the Repo running on Google App Engine.
27
# Deployments take a non-trivial amount of time and can often be avoided, so
28
# see if our app is running on App Engine before trying to re-upload it.
29
def initialize(credentials)
30
if credentials.class != Hash
31
raise BadConfigurationException.new("Credentials was not a Hash")
34
if credentials['@appid'].nil?
35
raise BadConfigurationException.new("No @appid was provided")
38
if credentials['@appcfg_cookies'].nil?
39
raise BadConfigurationException.new("No @appcfg_cookies was provided")
42
appid = credentials['@appid']
43
@host = "#{appid}.appspot.com"
46
app_location = "/root/appscale/AppServer/demos/therepo/"
47
TaskEngineGoogleAppEngine.upload_app(credentials, app_location)
52
# Sees if the Repo application is running at the @host we've set for it.
54
result = do_http_get_for_get("/any-path", "any-type")
56
Djinn.log_debug("App appears to be running")
59
Djinn.log_debug("App isn't running")