Beispiel #1
0
def query(env):
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned.

    :param env: Serves no purpose for the query data but is required for the
        select field in the environment block
    :type env: :obj:`string`
    """
    if app.config["ENABLE_QUERY"]:
        envs = environments()
        check_env(env, envs)

        form = QueryForm(meta={"csrf_secret": app.config["SECRET_KEY"], "csrf_context": session})
        if form.validate_on_submit():
            if form.endpoints.data == "pql":
                query = form.query.data
            elif form.query.data[0] == "[":
                query = form.query.data
            else:
                query = "[{0}]".format(form.query.data)
            result = get_or_abort(puppetdb._query, form.endpoints.data, query=query)
            return render_template("query.html", form=form, result=result, envs=envs, current_env=env)
        return render_template("query.html", form=form, envs=envs, current_env=env)
    else:
        log.warn("Access to query interface disabled by administrator..")
        abort(403)
Beispiel #2
0
def query(env):
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned.

    :param env: Serves no purpose for the query data but is required for the
        select field in the environment block
    :type env: :obj:`string`
    """
    check_env(env)

    if app.config['ENABLE_QUERY']:
        form = QueryForm()
        if form.validate_on_submit():
            if form.query.data[0] == '[':
                query = form.query.data
            else:
                query = '[{0}]'.format(form.query.data)
            result = get_or_abort(puppetdb._query,
                                  form.endpoints.data,
                                  query=query)
            return render_template('query.html',
                                   form=form,
                                   result=result,
                                   envs=envs,
                                   current_env=env)
        return render_template('query.html',
                               form=form,
                               envs=envs,
                               current_env=env)
    else:
        log.warn('Access to query interface disabled by administrator..')
        abort(403)
Beispiel #3
0
def query():
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned."""
    form = QueryForm()
    if form.validate_on_submit():
        result = get_or_abort(puppetdb._query, form.endpoints.data, query="[{0}]".format(form.query.data))
        return render_template("query.html", form=form, result=result)
    return render_template("query.html", form=form)
Beispiel #4
0
def query():
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned."""
    form = QueryForm()
    if form.validate_on_submit():
        result = get_or_abort(puppetdb._query, form.endpoints.data,
                query='[{0}]'.format(form.query.data))
        return render_template('query.html', form=form, result=result)
    return render_template('query.html', form=form)
Beispiel #5
0
def query():
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned."""
    if app.config['ENABLE_QUERY']:
      form = QueryForm()
      if form.validate_on_submit():
          result = get_or_abort(puppetdb._query, form.endpoints.data,
                  query='[{0}]'.format(form.query.data))
          return render_template('query.html', form=form, result=result)
      return render_template('query.html', form=form)
    else:
        log.warn('Access to query interface disabled by administrator..')
        abort(403)
Beispiel #6
0
def query():
    """Allows to execute raw, user created querries against PuppetDB. This is
    currently highly experimental and explodes in interesting ways since none
    of the possible exceptions are being handled just yet. This will return
    the JSON of the response or a message telling you what whent wrong /
    why nothing was returned."""
    if app.config['ENABLE_QUERY']:
        form = QueryForm()
        if form.validate_on_submit():
            if form.query.data[0] == '[':
                query = form.query.data
            else:
                query = '[{0}]'.format(form.query.data)
            result = get_or_abort(puppetdb._query,
                                  form.endpoints.data,
                                  query=query)
            return render_template('query.html', form=form, result=result)
        return render_template('query.html', form=form)
    else:
        log.warn('Access to query interface disabled by administrator..')
        abort(403)