From: Imran Imtiaz Date: Thu, 20 Nov 2025 14:45:32 +0000 (+0000) Subject: mgr/dashboard: add GET API endpoint for consistency groups X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F66340%2Fhead;p=ceph.git mgr/dashboard: add GET API endpoint for consistency groups Signed-off-by: Imran Imtiaz 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. --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index fab2bfb1a04..81055562174 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -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'), diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 6ac1c229a9f..ca7683f12c7 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -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: