summaryrefslogtreecommitdiffstats
path: root/src/pybind/rados/rados.pyx
diff options
context:
space:
mode:
authorMykola Golub <mgolub@suse.com>2020-03-11 12:28:26 +0100
committerMykola Golub <mgolub@suse.com>2020-03-11 15:39:11 +0100
commit0ec9cfcf13a1346a628962d315ed19a37e398eba (patch)
tree746e33968bc53c7cd3f5a15c571a49550da0490e /src/pybind/rados/rados.pyx
parentMerge pull request #33844 from tchaikov/wip-crimson-mgr-reconnect (diff)
downloadceph-0ec9cfcf13a1346a628962d315ed19a37e398eba.tar.xz
ceph-0ec9cfcf13a1346a628962d315ed19a37e398eba.zip
pybind/rados: add Ioctx dup method
Signed-off-by: Mykola Golub <mgolub@suse.com>
Diffstat (limited to 'src/pybind/rados/rados.pyx')
-rw-r--r--src/pybind/rados/rados.pyx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx
index 79016893731..0a24315390c 100644
--- a/src/pybind/rados/rados.pyx
+++ b/src/pybind/rados/rados.pyx
@@ -1302,7 +1302,7 @@ Rados object in state %s." % self.state)
ret = rados_ioctx_create(self.cluster, _ioctx_name, &ioctx)
if ret < 0:
raise make_ex(ret, "error opening pool '%s'" % ioctx_name)
- io = Ioctx(ioctx_name)
+ io = Ioctx(self, ioctx_name)
io.io = ioctx
return io
@@ -1328,7 +1328,7 @@ Rados object in state %s." % self.state)
ret = rados_ioctx_create2(self.cluster, _pool_id, &ioctx)
if ret < 0:
raise make_ex(ret, "error opening pool id '%s'" % pool_id)
- io = Ioctx(str(pool_id))
+ io = Ioctx(self, str(pool_id))
io.io = ioctx
return io
@@ -2285,7 +2285,8 @@ cdef class Ioctx(object):
"""rados.Ioctx object"""
# NOTE(sileht): attributes declared in .pyd
- def __init__(self, name):
+ def __init__(self, rados, name):
+ self.rados = rados
self.name = name
self.state = "open"
@@ -2347,6 +2348,15 @@ cdef class Ioctx(object):
completion_obj.rados_comp = completion
return completion_obj
+ def dup(self):
+ """
+ Duplicate IoCtx
+ """
+
+ ioctx = self.rados.open_ioctx2(self.get_pool_id())
+ ioctx.set_namespace(self.get_namespace())
+ return ioctx
+
@requires(('object_name', str_type), ('oncomplete', opt(Callable)))
def aio_stat(self, object_name, oncomplete):
"""