Commit Graph

9 Commits

Author SHA1 Message Date
Wido den Hollander
3f0428ac3a
rest api: Set application variable when not executed as __main__
This allows for using this Python file as a WSGI module as it expects
a variable called application.

Signed-off-by: Wido den Hollander <wido@42on.com>
2017-06-26 11:50:50 +02:00
Wido den Hollander
00346f6887
rest api: Set default ceph.conf and id options
This allows for easy execution of the REST API:

  $ /usr/bin/ceph-rest-api

Signed-off-by: Wido den Hollander <wido@42on.com>
2017-06-26 11:50:34 +02:00
Sage Weil
2437693309 ceph-rest-api: drop autotools detection
Signed-off-by: Sage Weil <sage@redhat.com>
2016-09-26 15:50:30 -04:00
Dan Mick
b9000b314b Invoke python with /usr/bin/env python instead of directly
Fixes: #6311
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-09-30 14:58:11 -07:00
Dan Mick
8af47755af ceph-rest-api: clean up options/environment
ceph-rest-api:
* create app from wrapper by calling generate_app()
* pass args to generate_app() (early parsed in wrapper)
* parse -i/--id here as well
* set addr:port on returned app object
* handle only EnvironmentError exceptions; let others spew traceback
* turn off debug when running singlethreaded server

ceph_rest_api.py:
* put glob.* on app.ceph_* instead; pass around app in init code
* drop conf parsing (let librados do its job)

Documentation updated to match.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-07-26 21:38:12 -07:00
Dan Mick
cc10988850 ceph-rest-api: separate into module and front-end for WSGI deploy
To deploy ceph-rest-api within a WSGI server (apache/mod_wsgi,
nginx/uwsgi, etc.), there needs to be an importable (.py) module
that performs all init/config when imported.  ceph-rest-api was
close, but it needs to be named properly, and there's no argument
passing, so it needs to get args from a fixed file or the env.

Separate most of ceph-rest-api into pybind/ceph_rest_api.py, and make
its arguments come from the environment, and init errors be
ImportError exceptions.  Recase ceph-rest-api as a thin layer that
does the usual setup and arg parsing, and then sets args into the
environment and imports ceph_rest_api.py, catching exceptions and
reporting errors.  This allows standalone execution as usual.
ceph-rest-api grabs a few module globals (addr/port and the flask.app)
to use after it imports.

Accept cluster name, and do the ceph.conf search using cluster name
in the appropriate places in the searched-for files.

Also ceph_rest_api.py gets a little cleanup (fewer global variables,
cleaner conf file search algorithm, better error reporting on conf
load)

Also: doc updates, packaging updates to include ceph_rest_api.py

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-12 16:37:32 -07:00
Dan Mick
3d25f46112 ceph-rest-api: make main program be "shell" around WSGI guts
Move WSGI guts to pybind/ceph_rest_api.py for importability
into WSGI server frameworks.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-11 17:17:39 -07:00
Dan Mick
5a6251c80d ceph-rest-api: connect to cluster with configured client name
Spotted by Noah Watkins

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-10 21:55:38 -07:00
Dan Mick
4cb0e06266 Add 'ceph-rest-api'
ceph-rest-api is a Python WSGI module for accessing the Ceph cluster.
It supports most of the commands supported by the ceph CLI,
appropriately translated to HTTP GET/PUT requests.  It is not a
truly RESTful interface.

Not supported at this moment: "tell", "pg <pgid>", and "daemon"
commands.

Configuration options are specified in ceph.conf, specified with
-c/--conf or obtained from $CEPH_CONF, /etc/ceph/ceph.conf,
~/.ceph/ceph.conf, or ./ceph.conf.

-n/--name specifies the client name, used for the cluster
authentication key and for the ceph.conf section name (default
is client.restapi).

        restapi keyring = <keyring file>
        restapi public addr = listenIP:port (default 0.0.0.0:5000)
        restapi base url = <base path> (default /api/v0.1)
        restapi log level = (error, warning, info, debug)
        restapi log file = (default /var/log/ceph/<clientname>.log)

Primitive human-level command discovery is supported; GET from
BASEURL (say, http://localhost:5000/api/v0.1) will show an HTML
table of all commands and arguments, method supported, and help strings.

Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-07-10 20:58:51 -07:00