From: Will Smith Date: Fri, 23 Jul 2021 19:18:12 +0000 (-0400) Subject: rbd: Fix mirror_image_get_status in rbd python bindings X-Git-Tag: v16.2.6~24^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f55433547f9a56bcff31c7640e33411377fc2822;p=ceph.git rbd: Fix mirror_image_get_status in rbd python bindings When retrieving the status of a mirrored image from the Python rbd library, a TypeError is raised. *To Reproduce:* Set up two Ceph clusters for block storage, and configure image mirroring between their pools. Create a least one image with mirroring enabled, then run the following script on either cluster (once the image exists everywhere): ```python import rados, rbd CONF_PATH = "YOUR-CONF-PATH" POOL_NAME = "YOUR-POOL-NAME" IMAGE_LABEL = "YOUR-IMAGE-LABEL" with rados.Rados(conffile=CONF_PATH) as cluster: with cluster.open_ioctx(POOL_NAME) as ioctx: with rbd.Image(ioctx, IMAGE_LABEL) as image: image.mirror_image_get_status() ``` This will result in the following stack trace: ``` Traceback (most recent call last): File "repo-bug.py", line 10, in image.mirror_image_get_status() File "rbd.pyx", line 3363, in rbd.requires_not_closed.wrapper File "rbd.pyx", line 5209, in rbd.Image.mirror_image_get_status TypeError: list indices must be integers or slices, not str ``` Fixes: https://tracker.ceph.com/issues/51867 Signed-off-by: Will Smith (cherry picked from commit 5dfda932b2012bb11a1860d8a81de3208b17f622) --- diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index 82dd0b47fce3..b05422c55429 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -4642,7 +4642,7 @@ written." % (self.name, ret, length)) if mirror_uuid == '': local_status = site_status else: - site_statuses['mirror_uuid'] = mirror_uuid + site_status['mirror_uuid'] = mirror_uuid site_statuses += site_status status = { 'name': decode_cstr(c_status.name),