]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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>
Fri, 14 Jun 2024 07:20:22 +0000 (09:20 +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>
(cherry picked from commit 533943d08f58c5da918adf473123357f85b341d5)

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 df176a410a940058cc5b95dab4280995ec2fe25e..42288870e4c6922b83e148e96a9412ec558df7fe 100644 (file)
@@ -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)