From a972b506b14127b8f0d9ac733f74ce2105bcadd4 Mon Sep 17 00:00:00 2001 From: Imran Imtiaz Date: Mon, 10 Nov 2025 12:47:33 +0000 Subject: [PATCH] mgr/dashboard: add API endpoint to list consistency groups mgr/dashboard: incorporate review comments fo groups API endpoint Fixes: https://tracker.ceph.com/issues/73689 Signed-off-by: Imran Imtiaz (cherry picked from commit 42c75ff73f748fbc744775b8de2d17ebf680c7c3) --- src/pybind/mgr/dashboard/controllers/rbd.py | 29 ++++++++++++++ src/pybind/mgr/dashboard/openapi.yaml | 44 +++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 90437cada70..591a04e676d 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -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 diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 7ae5c34715f..a2009eb3098 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -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: @@ -19305,6 +19347,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 -- 2.47.3