Created
May 28, 2014 13:52
-
-
Save wido/8bf032e5f482bfef949c to your computer and use it in GitHub Desktop.
Ceph REST API WSGI wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
WSGI wrapper for the Ceph REST API to be run behind Apache with mod_wsgi. | |
Place this script in /var/www as ceph-rest-api.wsgi and use this VirtualHost: | |
<VirtualHost *:80> | |
DocumentRoot /var/www | |
ServerName ceph-rest-api | |
ErrorLog /var/log/apache2/error.log | |
CustomLog /var/log/apache2/access.log combined | |
WSGIScriptAlias / /var/www/ceph-rest-api.wsgi | |
</VirtualHost> | |
You have to specify a Ceph configuration file to use, that will be used | |
to detect which monitors to connect to and which keyring to use. | |
A sample Ceph configuration: | |
[global] | |
keyring = /var/www/ceph.client.admin.keyring | |
mon_host = 1.2.3.4,2.3.4.5,3.4.5.6 | |
log_file = /dev/null | |
Make sure that the configuration file and keyring are readable by the webserver. | |
Logging has to be disabled, otherwise librados will try to create a logfile | |
in /var/log which is not allowed by when running under the webserver's user. | |
Now go to http://localhost/api/v0.1 and you should see the API! | |
Tested with: | |
- Ubuntu 14.04 | |
- Apache 2.4 (apache2-mpm-worker) | |
- mod_wsgi (libapache2-mod-wsgi) | |
- Python 2.7.6 | |
''' | |
conffile="/var/www/ceph.conf" | |
cluster="ceph" | |
clientname=None | |
clientid="admin" | |
args=None | |
import ceph_rest_api | |
application = ceph_rest_api.generate_app(conffile, cluster, clientname, clientid, args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment