From: Kotresh HR Date: Wed, 4 Mar 2020 12:03:34 +0000 (+0530) Subject: libcephfs/pybind: Add get_pool_id, get_pool_replication X-Git-Tag: v16.1.0~2070^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e8b9271db96855231dc32080208ccecf65c09e32;p=ceph.git libcephfs/pybind: Add get_pool_id, get_pool_replication Fixes: https://tracker.ceph.com/issues/44171 Signed-off-by: Kotresh HR --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 07b17067609c..9fee58933fd5 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -225,6 +225,8 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_futimens(ceph_mount_info *cmount, int fd, timespec times[2]) int ceph_get_file_replication(ceph_mount_info *cmount, int fh) int ceph_get_path_replication(ceph_mount_info *cmount, const char *path) + int ceph_get_pool_id(ceph_mount_info *cmount, const char *pool_name) + int ceph_get_pool_replication(ceph_mount_info *cmount, int pool_id) class Error(Exception): @@ -2195,3 +2197,44 @@ cdef class LibCephFS(object): raise make_ex(ret, "error in get_path_replication") return ret + + def get_pool_id(self, pool_name): + """ + Get the id of the named pool. + + :param pool_name: the name of the pool. + """ + + self.require_state("mounted") + pool_name = cstr(pool_name, 'pool_name') + + cdef: + char* _pool_name = pool_name + + with nogil: + ret = ceph_get_pool_id(self.cluster, _pool_name) + if ret < 0: + raise make_ex(ret, "error in get_pool_id") + + return ret + + def get_pool_replication(self, pool_id): + """ + Get the pool replication factor. + + :param pool_id: the pool id to look up + """ + + self.require_state("mounted") + if not isinstance(pool_id, int): + raise TypeError('pool_id must be an int') + + cdef: + int _pool_id = pool_id + + with nogil: + ret = ceph_get_pool_replication(self.cluster, _pool_id) + if ret < 0: + raise make_ex(ret, "error in get_pool_replication") + + return ret