]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add GET API endpoint for consistency groups 66340/head
authorImran Imtiaz <imran.imtiaz@uk.ibm.com>
Thu, 20 Nov 2025 14:45:32 +0000 (14:45 +0000)
committerImran Imtiaz <imran.imtiaz@uk.ibm.com>
Thu, 20 Nov 2025 16:03:33 +0000 (16:03 +0000)
Signed-off-by: Imran Imtiaz <imran.imtiaz@uk.ibm.com>
Fixes: https://tracker.ceph.com/issues/73942
Add a consistency group dashboard API endpoint to get the list of images
in the consistency groups that match the namespace of the group.

src/pybind/mgr/dashboard/controllers/rbd.py
src/pybind/mgr/dashboard/openapi.yaml

index fab2bfb1a0424fec400590e0159b762be1b28e5f..81055562174001c8a27d92646efa4bd037ada1e6 100644 (file)
@@ -45,6 +45,11 @@ RBD_GROUP_LIST_SCHEMA = [{
     "num_images": (int, '')
 }]
 
+RBD_GROUP_GET_SCHEMA = [{
+    "group": (str, 'group name'),
+    "images": ([str], '')
+}]
+
 
 # pylint: disable=not-callable
 def RbdTask(name, metadata, wait_for):  # noqa: N802
@@ -472,7 +477,7 @@ class RbdGroup(RESTController):
         self.rbd_inst = rbd.RBD()
 
     @handle_rbd_error()
-    @EndpointDoc("Display RBD Groups by pool name",
+    @EndpointDoc("List groups by pool name",
                  parameters={
                      'pool_name': (str, 'Name of the pool'),
                  },
@@ -491,7 +496,33 @@ class RbdGroup(RESTController):
             return result
 
     @handle_rbd_error()
-    @EndpointDoc("Create an RBD Group",
+    @EndpointDoc("Get the list of images in a group",
+                 parameters={
+                     'pool_name': (str, 'Name of the pool'),
+                     'group_name': (str, 'Name of the group'),
+                 },
+                 responses={200: RBD_GROUP_GET_SCHEMA})
+    @RESTController.Collection('GET', path='/{group_name}')
+    def get(self, pool_name, group_name, namespace=None):
+        with mgr.rados.open_ioctx(pool_name) as ioctx:
+            RbdService.validate_namespace(ioctx, namespace)
+            ioctx.set_namespace(namespace)
+            result = []
+            groups = self.rbd_inst.group_list(ioctx)
+            if group_name in groups:
+                result.append({
+                    'group': group_name,
+                    'images': list(rbd.Group(ioctx, group_name).list_images())
+                })
+            else:
+                raise DashboardException(
+                    msg='Group not found',
+                    code='group_not_found',
+                    component='rbd')
+            return result
+
+    @handle_rbd_error()
+    @EndpointDoc("Create a group",
                  parameters={
                      'pool_name': (str, 'Name of the pool'),
                      'name': (str, 'Name of the group'),
@@ -504,7 +535,7 @@ class RbdGroup(RESTController):
 
     @RESTController.Collection('POST', path='/{group_name}/image')
     @handle_rbd_error()
-    @EndpointDoc("Add an image to an RBD Group",
+    @EndpointDoc("Add image to a group",
                  parameters={
                      'pool_name': (str, 'Name of the pool'),
                      'group_name': (str, 'Name of the group'),
index 6ac1c229a9f7fba627823359f74a7a1dc8d878ee..ca7683f12c7203ed30677f5e4847179486bbfc4e 100755 (executable)
@@ -1634,7 +1634,7 @@ paths:
             trace.
       security:
       - jwt: []
-      summary: Display RBD Groups by pool name
+      summary: List groups by pool name
       tags:
       - RbdGroup
     post:
@@ -1680,7 +1680,62 @@ paths:
             trace.
       security:
       - jwt: []
-      summary: Create an RBD Group
+      summary: Create a group
+      tags:
+      - RbdGroup
+  /api/block/pool/{pool_name}/group/{group_name}:
+    get:
+      parameters:
+      - description: Name of the pool
+        in: path
+        name: pool_name
+        required: true
+        schema:
+          type: string
+      - description: Name of the group
+        in: path
+        name: group_name
+        required: true
+        schema:
+          type: string
+      - allowEmptyValue: true
+        in: query
+        name: namespace
+        schema:
+          type: string
+      responses:
+        '200':
+          content:
+            application/vnd.ceph.api.v1.0+json:
+              schema:
+                items:
+                  properties:
+                    group:
+                      description: group name
+                      type: string
+                    images:
+                      description: ''
+                      items:
+                        type: string
+                      type: array
+                  type: object
+                required:
+                - group
+                - images
+                type: array
+          description: OK
+        '400':
+          description: Operation exception. Please check the response body for details.
+        '401':
+          description: Unauthenticated access. Please login first.
+        '403':
+          description: Unauthorized access. Please check your permissions.
+        '500':
+          description: Unexpected error. Please check the response body for the stack
+            trace.
+      security:
+      - jwt: []
+      summary: Get the list of images in a group
       tags:
       - RbdGroup
   /api/block/pool/{pool_name}/group/{group_name}/image:
@@ -1733,7 +1788,7 @@ paths:
             trace.
       security:
       - jwt: []
-      summary: Add an image to an RBD Group
+      summary: Add image to a group
       tags:
       - RbdGroup
   /api/block/pool/{pool_name}/namespace: