]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/rbd: expand what get_parent_image_spec() returns
authorIlya Dryomov <idryomov@gmail.com>
Sun, 9 Jun 2024 08:08:00 +0000 (10:08 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 13 Jun 2024 12:08:46 +0000 (14:08 +0200)
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 <idryomov@gmail.com>
qa/tasks/mgr/dashboard/test_rbd.py
src/pybind/rbd/rbd.pyx

index c2ffbd48e8a8507fc81a793ff29736c4fc500599..a872645e33ed94388f9f18b343620ccdebf6fe5f 100644 (file)
@@ -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)
index 0b0b64670ec6373fc59b647a7fefc2da26c22a9b..6650b08c935be45e6a801c7419b8b728c9f91fdb 100644 (file)
@@ -3187,9 +3187,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
@@ -3202,9 +3216,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)