From: David Coles Date: Tue, 20 Oct 2015 17:55:44 +0000 (-0700) Subject: pybind: Import cstr from the rados module X-Git-Tag: v10.0.1~80^2~7^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63f5462cbd36b29596920a05043fe36ec3d9037a;p=ceph.git pybind: Import cstr from the rados module Since rados is required for rbd, we can avoid duplication of code across these two modules. Signed-off-by: David Coles --- diff --git a/src/pybind/rbd.py b/src/pybind/rbd.py index c15a943be76..b0bf552ebf4 100644 --- a/src/pybind/rbd.py +++ b/src/pybind/rbd.py @@ -20,6 +20,8 @@ import ctypes import errno import sys +from rados import cstr + ANONYMOUS_AUID = 0xffffffffffffffff ADMIN_AUID = 0 @@ -202,23 +204,6 @@ def load_librbd(): raise EnvironmentError("Unable to load librbd: %s" % e) -def cstr(val, encoding="utf-8"): - """ - Create a C-style string from a Python string - - :param str val: Python string - :rtype: c_char_p - """ - if val is None: - return c_char_p(None) - - if _python2 and isinstance(val, str): - # Don't encode str on Python 2, as it's already an 8-bit string - return c_char_p(val) - else: - return c_char_p(val.encode(encoding)) - - class RBD(object): """ This class wraps librbd CRUD functions.