]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
rbd: Fix mirror_image_get_status in rbd python bindings
authorWill Smith <wsmith@linode.com>
Fri, 23 Jul 2021 19:18:12 +0000 (15:18 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Aug 2021 12:18:20 +0000 (14:18 +0200)
commit2172a317fb8eb1af37d6e745109939d5aef81943
treeea6d734d72469fa35bdcf78e419b81908a794ab4
parent8b7c3fee571cce43bfec1dd1c867addf0af1de65
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 <module>
    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 <wsmith@linode.com>
(cherry picked from commit 5dfda932b2012bb11a1860d8a81de3208b17f622)
src/pybind/rbd/rbd.pyx