예제 #1
0
def get_filetree():
    cache_path = os.path.sep.join([loader.get_cache_directory(), "filetree"])
    default = fetch_filetree
    if "refresh" in request.args:
        refresh = request.args["refresh"].lower() == "true"
        filetree = loader.load_cache(cache_path, default, refresh)
    else:
        filetree = loader.load_cache(cache_path, default)
    return jsonify(filetree)
예제 #2
0
def get_filetree_info(hostname):
    cache_path = os.path.sep.join([loader.get_cache_directory(), "filetree"])
    default = fetch_filetree
    filetree_cache = loader.load_cache(cache_path, default)

    if not hostname in filetree_cache:
        return flask.jsonify(error="No such hostname"), 404

    if not filetree_cache[hostname]["data"] != {}:
        return []

    paths = [x["name"] for x in filetree_cache[hostname]["data"]["flat"]]
    return [os.path.sep.join([ansible_config["remote_site_root"], path[1:]]) for path in paths]