]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add API endpoint to list consistency groups 66184/head
authorImran Imtiaz <imran.imtiaz@uk.ibm.com>
Mon, 10 Nov 2025 12:47:33 +0000 (12:47 +0000)
committerImran Imtiaz <imran.imtiaz@uk.ibm.com>
Wed, 12 Nov 2025 09:27:35 +0000 (09:27 +0000)
mgr/dashboard: incorporate review comments fo groups API endpoint

Fixes: https://tracker.ceph.com/issues/73689
Signed-off-by: Imran Imtiaz <imran.imtiaz@uk.ibm.com>
src/pybind/mgr/dashboard/controllers/rbd.py
src/pybind/mgr/dashboard/openapi.yaml

index 90437cada70bc89d51a4a8887a34d861a0ca5fa3..591a04e676d2816008ea7d9671418b2365751da7 100644 (file)
@@ -40,6 +40,11 @@ RBD_TRASH_SCHEMA = [{
     "pool_name": (str, 'pool name')
 }]
 
+RBD_GROUP_LIST_SCHEMA = [{
+    "group": (str, 'group name'),
+    "num_images": (int, '')
+}]
+
 
 # pylint: disable=not-callable
 def RbdTask(name, metadata, wait_for):  # noqa: N802
@@ -457,3 +462,27 @@ class RbdNamespace(RESTController):
                     'num_images': len(images) if images else 0
                 })
             return result
+
+
+@APIRouter('/block/pool/{pool_name}/group', Scope.RBD_IMAGE)
+@APIDoc("RBD Group Management API", "RbdGroup")
+class RbdGroup(RESTController):
+    def __init__(self):
+        super().__init__()
+        self.rbd_inst = rbd.RBD()
+
+    @EndpointDoc("Display RBD Groups by pool name",
+                 parameters={
+                     'pool_name': (str, 'Name of the pool'),
+                 },
+                 responses={200: RBD_GROUP_LIST_SCHEMA})
+    def list(self, pool_name):
+        with mgr.rados.open_ioctx(pool_name) as ioctx:
+            result = []
+            groups = self.rbd_inst.group_list(ioctx)
+            for group in groups:
+                result.append({
+                    'group': group,
+                    'num_images': len(list(rbd.Group(ioctx, group).list_images()))
+                })
+            return result
index 62414d628e7903f060f65e9117f708292752e4ab..b37b25424b6705b663416c13fdcbbacf1f98282e 100755 (executable)
@@ -1590,6 +1590,48 @@ paths:
       - jwt: []
       tags:
       - RbdMirroringSummary
+  /api/block/pool/{pool_name}/group:
+    get:
+      parameters:
+      - description: Name of the pool
+        in: path
+        name: pool_name
+        required: true
+        schema:
+          type: string
+      responses:
+        '200':
+          content:
+            application/vnd.ceph.api.v1.0+json:
+              schema:
+                items:
+                  properties:
+                    group:
+                      description: group name
+                      type: string
+                    num_images:
+                      description: ''
+                      type: integer
+                  type: object
+                required:
+                - group
+                - num_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: Display RBD Groups by pool name
+      tags:
+      - RbdGroup
   /api/block/pool/{pool_name}/namespace:
     get:
       parameters:
@@ -19295,6 +19337,8 @@ tags:
   name: RGW Topic Management
 - description: RBD Management API
   name: Rbd
+- description: RBD Group Management API
+  name: RbdGroup
 - description: RBD Mirroring Management API
   name: RbdMirroring
 - description: RBD Mirroring Pool Bootstrap Management API