Giter Club home page Giter Club logo

python-cephclient's Introduction

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

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

RELEASE NOTES

0.1.0.5

dmsimard:

  • Add missing dependency on the requests library
  • Some PEP8 and code standardization cleanup
  • Add root "PUT" methods
  • Add mon "PUT" methods
  • Add mds "PUT" methods
  • Add auth "PUT" methods

Donald Talton:

  • Add osd "PUT" methods

0.1.0.4

  • Fix setup and PyPi installation

0.1.0.3

  • GET API calls under '/tell' have been implemented.
  • GET API calls are are in root (/) have been renamed to be coherent with incoming future development

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

python-cephclient's People

Contributors

dankcodenugs avatar dmsimard avatar gooseyard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-cephclient's Issues

Add unit tests

It's a bit early to add unit tests considering the code changes a LOT and I don't want to have that overhead during early development.
However, unit tests eventually need to be done before version I consider releasing 1.0.

Installation problem @Ubuntu 14.04.1 LTS

Installation command: pip install python ends with:

"/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1"

Please add zlib1g-dev package as a dependency.

Map PUT requests

Before implementing PUT requests, need to map them to a function first and raise a FunctionNotImplemented exception.

put "tell" to rest-api does not get right response

I clone the python-cephclient mater to my VM machine,use setup.py build and install to Ubuntu,then start my test,I got an error below :

root@ubuntu:/home/python-cephclient# python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from cephclient.wrapper import *
wrapper = CephWrapper(
... endpoint = 'http://192.168.182.139:5000/api/v0.1/',
... debug = True # Optionally increases the verbosity of the client
... )
Jul 24 00:17:09 - client.py - DEBUG - Params: {'debug': True, 'endpoint': 'http://192.168.182.139:5000/api/v0.1/'}

And from the ceph-rest-api "server" ,I got these prints:

ceph-rest-api -c /etc/ceph/ceph.conf --cluster ceph -i admin

  • Running on http://0.0.0.0:5000/
    192.168.182.149 - - [24/Jul/2014 15:19:34] "PUT /api/v0.1/tell?target=osd.0&args=dump_historic_ops HTTP/1.1" 400 -

redundant character '/' before tell GET calls

I tried each tell_* functions in wrapper class, I found there were redundant character '/' ,these character will lead err response when tell_* functions been called.
sorry for my very bad english

hello,i got a problem when i run module

i follow you guide,pip install python-cephclient,and write the code:
from cephclient.wrapper import *

wrapper = CephWrapper(
endpoint = 'http://127.0.0.1:5000/api/v0.1/',
debug = True
)

response, body = wrapper.get_fsid(body = 'json')

but i got the problem :
response, body = wrapper.get_fsid(body = 'json')
AttributeError: 'CephWrapper' object has no attribute 'get_fsid'
there is not attribute 'get_fsid',what is the problem?

documentation

hi. great that you working on this project. did not find any documentation on client implemented methods. could you help me with that? maybe my search was not so well. thanks in advance.

Please update PIP

Hi!

Can you please update PIP with the latest & greatest python-cephclient?

Thanks in advance!

Install by pip fails


/usr/bin/pip run on Fri Jan 31 21:04:25 2014
Downloading/unpacking python-cephclient
Getting page http://pypi.python.org/simple/python-cephclient
URLs to search for versions for python-cephclient:

Installed /home/ubuntu/build/python-cephclient/pbr-0.5.23-py2.7.egg

error in setup command: Error parsing /home/ubuntu/build/python-cephclient/setup.cfg: OSError: [Errno 2] No such file or directory


Command python setup.py egg_info failed with error code 1
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 223, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 980, in prepare_files
req_to_install.run_egg_info()
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 216, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/lib/python2.7/dist-packages/pip/init.py", line 255, in call_subprocess
% (command_desc, proc.returncode))
InstallationError: Command python setup.py egg_info failed with error code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.