]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rados: add rados.version
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 17 Feb 2011 18:05:10 +0000 (10:05 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 17 Feb 2011 18:05:10 +0000 (10:05 -0800)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/pybind/rados.py
src/test/pybind-test.py

index 46c72ab095ab4b73e9fc041fc70d7003ba330aef..59d027335890be643e8c4635353093717872b3ef 100755 (executable)
@@ -66,6 +66,15 @@ class rados_pool_stat_t(Structure):
                 ("num_wr", c_uint64),
                 ("num_wr_kb", c_uint64)]
 
+class Version(object):
+    def __init__(self, major, minor, extra):
+        self.major = major
+        self.minor = minor
+        self.extra = extra
+
+    def __str__(self):
+        return "%d.%d.%d" % (self.major, self.minor, self.extra)
+
 class Rados(object):
     """librados python wrapper"""
     def __init__(self):
@@ -79,6 +88,14 @@ class Rados(object):
         if (self.__dict__.has_key("initialized") and self.initialized == True):
             self.librados.rados_deinitialize()
 
+    def version(self):
+        major = ctypes.c_int()
+        minor = ctypes.c_int()
+        extra = ctypes.c_int()
+        ret = self.librados.librados_version(byref(major), byref(minor),\
+                                            byref(extra))
+        return Version(major.value, minor.value, extra.value)
+
     def create_pool(self, pool_name):
         ret = self.librados.rados_create_pool(c_char_p(pool_name))
         if ret < 0:
index 8fd4f8f8ccd574a04f06afffa49a76a1df6f46d6..ea48fb0ad91f36e74d67bb0346031917c942aab5 100755 (executable)
@@ -4,6 +4,8 @@ import rados
 
 # Create and destroy a pool
 r = rados.Rados()
+v = r.version()
+print "rados version %s" % str(v)
 try:
     r.create_pool("foo2")
     print "created pool foo2"