Skip to main content

A client library in python for the Ceph REST API.

Project description

python-cephclient is a python module to communicate with Ceph’s REST API (ceph-rest-api).

This is currently a work in progress.

ABOUT

Client

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.

Wrapper

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.

Development, Feedback, Bugs

Want to contribute ? Feel free to send pull requests !

Have problems, bugs, feature ideas ? I am using the github issue tracker to manage them.

HOW TO USE

Installation

Install the package through pip:

pip install python-cephclient

Instanciate CephWrapper:

from cephclient 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' >

RELEASE NOTES

0.1.0.2

  • Implemented or fixed missing GET calls (All API GET calls that are not under the ‘/tell’ namespace are now supported)

  • Client can optionally raise an exception when requesting a unsupported body type for a provided API call (ex: requesting json through the wrapper for a call that is known to only return binary will raise an exception)

  • Client now supports binary type responses (ex: crush map, mon map, etc)

  • Improved the README (!)

0.1.0.1

  • First public release of python-cephclient

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-cephclient-0.1.0.2.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file python-cephclient-0.1.0.2.tar.gz.

File metadata

File hashes

Hashes for python-cephclient-0.1.0.2.tar.gz
Algorithm Hash digest
SHA256 44afcae231dcb5cc4b4cfc74f619eafa0c6360b0a5ae1834b14953bfd27ebb26
MD5 2e36d492c3119facb92a0c3ad33783e4
BLAKE2b-256 b4e57016af165d53c0a3d63b7515e6d54b263aa99a9871d6634f26b23247678a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page