From: Ilya Dryomov Date: Sun, 9 Jun 2024 08:08:00 +0000 (+0200) Subject: pybind/rbd: expand what get_parent_image_spec() returns X-Git-Tag: v19.1.1~206^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97252279a2cd852700f4b7931d51081f51300536;p=ceph.git pybind/rbd: expand what get_parent_image_spec() returns Propagate everything there is in rbd_linked_image_spec_t and rbd_snap_spec_t structures returned by the C API. Signed-off-by: Ilya Dryomov (cherry picked from commit 533943d08f58c5da918adf473123357f85b341d5) --- diff --git a/qa/tasks/mgr/dashboard/test_rbd.py b/qa/tasks/mgr/dashboard/test_rbd.py index c2ffbd48e8a8..a872645e33ed 100644 --- a/qa/tasks/mgr/dashboard/test_rbd.py +++ b/qa/tasks/mgr/dashboard/test_rbd.py @@ -236,9 +236,14 @@ class RbdTest(DashboardTestCase): 'features_name': JList(JLeaf(str)), 'stripe_count': JLeaf(int, none=True), 'stripe_unit': JLeaf(int, none=True), - 'parent': JObj(sub_elems={'pool_name': JLeaf(str), + 'parent': JObj(sub_elems={'pool_id': JLeaf(int), + 'pool_name': JLeaf(str), 'pool_namespace': JLeaf(str, none=True), + 'image_id': JLeaf(str), 'image_name': JLeaf(str), + 'trash': JLeaf(bool), + 'snap_id': JLeaf(int), + 'snap_namespace_type': JLeaf(int), 'snap_name': JLeaf(str)}, none=True), 'data_pool': JLeaf(str, none=True), 'snapshots': JList(JLeaf(dict)), @@ -256,7 +261,12 @@ class RbdTest(DashboardTestCase): self.assertSchema(img, schema) for k, v in kwargs.items(): - if isinstance(v, list): + if k == 'parent' and v is not None: + # check that img['parent'] contains (is a superset of) v + actual = {pk: img['parent'][pk] + for pk in v.keys() if pk in img['parent']} + self.assertEqual(actual, v) + elif isinstance(v, list): self.assertSetEqual(set(img[k]), set(v)) else: self.assertEqual(img[k], v) diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index df176a410a94..42288870e4c6 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -3164,9 +3164,23 @@ cdef class Image(object): Get spec of the cloned image's parent :returns: dict - contains the following keys: + + * ``pool_id`` (int) - parent pool id + * ``pool_name`` (str) - parent pool name + * ``pool_namespace`` (str) - parent pool namespace + + * ``image_id`` (str) - parent image id + * ``image_name`` (str) - parent image name + + * ``trash`` (bool) - True if parent image is in trash bin + + * ``snap_id`` (int) - parent snapshot id + + * ``snap_namespace_type`` (int) - parent snapshot namespace type + * ``snap_name`` (str) - parent snapshot name :raises: :class:`ImageNotFound` if the image doesn't have a parent @@ -3179,9 +3193,14 @@ cdef class Image(object): if ret != 0: raise make_ex(ret, 'error getting parent info for image %s' % self.name) - result = {'pool_name': decode_cstr(parent_spec.pool_name), + result = {'pool_id': parent_spec.pool_id, + 'pool_name': decode_cstr(parent_spec.pool_name), 'pool_namespace': decode_cstr(parent_spec.pool_namespace), + 'image_id': decode_cstr(parent_spec.image_id), 'image_name': decode_cstr(parent_spec.image_name), + 'trash': parent_spec.trash, + 'snap_id': snap_spec.id, + 'snap_namespace_type': snap_spec.namespace_type, 'snap_name': decode_cstr(snap_spec.name)} rbd_linked_image_spec_cleanup(&parent_spec)