Beispiel #1
0
def delete_app(id):
    # retrieves both the directory to used as the
    # base for the sun files and the directory used
    # to store the repositories
    suns_folder = util.get_suns_folder()
    repos_folder = util.get_repos_folder()

    # retrieves the current mongo database and removes the
    # app entry contained in it
    db = quorum.get_mongo_db()
    db.apps.remove({"id" : id})

    # retrieves the (complete) repository path for the current app
    # and removes the repository directory
    repo_path = os.path.join(repos_folder, "%s.git" % id)
    shutil.rmtree(repo_path)

    # retrieves the (complete) sun path for the current app and
    # removes the sun file from the file system
    sun_path = os.path.join(suns_folder, "%s.sun" % id)
    if os.path.exists(sun_path): os.remove(sun_path)

    return flask.redirect(
        flask.url_for("list_app")
    )
Beispiel #2
0
def restart_app(id):
    # retrieves the directory to be used as the
    # based for the sun files
    suns_folder = util.get_suns_folder()

    # creates the "full" path to the sun file associated
    # with the app with the provided id
    file_path = os.path.join(suns_folder, "%s.sun" % id)

    # retrieves the "clojure method" to be used in the
    # execution (restart) of the sun file and uses it
    # to execute the restart of the application
    execute_sun = util.get_execute_sun(id, file_path)
    quorum.run_back(execute_sun)

    return flask.redirect(
        flask.url_for("show_app", id = id)
    )
Beispiel #3
0
def deploy():
    # retrieves the name of the sun file to be deployed
    # and the contents of the file to be deployed
    name = quorum.get_field("name")
    file = quorum.get_field("file")

    # retrieves the directory to be used as the
    # based for the sun files
    suns_folder = util.get_suns_folder()

    # reads the complete file contents from the request and
    # then retrieves the associated sun file to update it
    contents = file.read()
    file_path = os.path.join(suns_folder, "%s.sun" % name)
    file = open(file_path, "wb")
    try: file.write(contents)
    finally: file.close()

    # retrieves the "clojure method" to be used in the
    # execution (deployment) of the sun file and uses it
    # to execute the deployment of the application
    execute_sun = util.get_execute_sun(name, file_path)
    quorum.run_back(execute_sun)
    return "success"