| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
python-cephclient is a python module to communicate with Ceph's REST API (ceph-rest-api).
This is currently a work in progress.
The cephclient class takes care of sending calls to the API through HTTP and handle the responses. It supports queries for JSON, XML, plain text or binary.
The wrapper class extends the client and provides helper functions to communicate with the API.
Nothing prevents you from calling the client directly exactly like the wrapper does. The wrapper exists for convenience.
Want to contribute ? Feel free to send pull requests !
Have problems, bugs, feature ideas ? I am using the github issue tracker to manage them.
Install the package through pip:
pip install python-cephclient
Installation does not work ?
python-cephclient depends on lxml which itself depends on some packages. To install lxml's dependencies on Ubuntu:
apt-get install python-dev libxml2-dev libxslt-dev
Instanciate CephWrapper:
from cephclient.wrapper import *
wrapper = CephWrapper(
endpoint = 'http://apiserver:5000/api/v0.1/',
debug = True # Optionally increases the verbosity of the client
)
Do your request and specify the reponse type you are expecting.
Either json, xml, text (default) or binary are available.
json:
response, body = wrapper.get_fsid(body = 'json')
print('Response: {0}, Body:\n{1}'.format(response, json.dumps(body, indent=4, separators=(',', ': '))))
====
Response: <Response [200]>, Body:
{
"status": "OK",
"output": {
"fsid": "d5252e7d-75bc-4083-85ed-fe51fa83f62b"
}
}
xml:
response, body = wrapper.get_fsid(body = 'xml')
print('Response: {0}, Body:\n{1}'.format(reponse, etree.tostring(body, pretty_print=True)))
====
Response: <Response [200]>, Body:
<response>
<output>
<fsid><fsid>d5252e7d-75bc-4083-85ed-fe51fa83f62b</fsid></fsid>
</output>
<status>
OK
</status>
</response>
text:
response, body = wrapper.get_fsid(body = 'text')
print('Response: {0}, Body:\n{1}'.format(response, body))
====
Response: <Response [200]>, Body:
d5252e7d-75bc-4083-85ed-fe51fa83f62b
binary:
response, body = wrapper.mon_getmap(body = 'binary') # < Do something binary with 'body' >
0.1.0.5
dmsimard:
Donald Talton:
0.1.0.4
0.1.0.3
0.1.0.2
0.1.0.1
| Back | FazBrowse Home | New Git URL |