From 79d8a4b57f4e8f313dcfb25aa15bc8721ce1b799 Mon Sep 17 00:00:00 2001 From: Imran Imtiaz Date: Wed, 24 Dec 2025 10:14:53 +0000 Subject: [PATCH] mgr/dashboard: add CRUD API endpoints for consistency group snapshots 2/2 Signed-off-by: Imran Imtiaz Fixes: https://tracker.ceph.com/issues/74275 Create a consistency group dashboard API endpoint to: - rollback - update Signed-off-by: Imran Imtiaz --- src/pybind/mgr/dashboard/controllers/rbd.py | 38 +++++++ src/pybind/mgr/dashboard/openapi.yaml | 112 ++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 5cb83900ee8b1..341360d1a2a9f 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -693,3 +693,41 @@ class RbdGroupSnapshot(RESTController): ioctx.set_namespace(namespace) group = rbd.Group(ioctx, group_name) return group.remove_snap(snapshot_name) + + @RbdTask('group_snap/update', + ['{pool_name}', '{group_name}', '{snapshot_name}'], 4.0) + @EndpointDoc("Update a group snapshot", + parameters={ + 'pool_name': (str, 'Name of the pool'), + 'group_name': (str, 'Name of the group'), + 'snapshot_name': (str, 'Current name of the snapshot'), + 'new_snap_name': (str, 'New name for the snapshot'), + }, + responses={200: None}) + def set(self, pool_name, group_name, snapshot_name, new_snap_name=None, namespace=None): + with mgr.rados.open_ioctx(pool_name) as ioctx: + RbdService.validate_namespace(ioctx, namespace) + ioctx.set_namespace(namespace) + group = rbd.Group(ioctx, group_name) + if new_snap_name and new_snap_name != snapshot_name: + return group.rename_snap(snapshot_name, new_snap_name) + return None + + @RbdTask('group_snap/rollback', + ['{pool_name}', '{group_name}', '{snapshot_name}'], 5.0) + @RESTController.Resource('POST') + @UpdatePermission + @allow_empty_body + @EndpointDoc("Rollback group to snapshot", + parameters={ + 'pool_name': (str, 'Name of the pool'), + 'group_name': (str, 'Name of the group'), + 'snapshot_name': (str, 'Name of the snapshot'), + }, + responses={200: None}) + def rollback(self, pool_name, group_name, snapshot_name, namespace=None): + with mgr.rados.open_ioctx(pool_name) as ioctx: + RbdService.validate_namespace(ioctx, namespace) + ioctx.set_namespace(namespace) + group = rbd.Group(ioctx, group_name) + return group.rollback_to_snap(snapshot_name) diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index dc17794bb8d43..cf32d3396b135 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -2181,6 +2181,118 @@ paths: summary: Get group snapshot information tags: - RbdGroupSnapshot + put: + 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 + - description: Current name of the snapshot + in: path + name: snapshot_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + namespace: + type: string + new_snap_name: + description: New name for the snapshot + type: string + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + schema: + properties: {} + type: object + description: Resource updated. + '202': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: Operation is still executing. Please check the task queue. + '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: Update a group snapshot + tags: + - RbdGroupSnapshot + /api/block/pool/{pool_name}/group/{group_name}/snap/{snapshot_name}/rollback: + post: + 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 + - description: Name of the snapshot + in: path + name: snapshot_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + namespace: + type: string + type: object + responses: + '201': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: Resource created. + '202': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: Operation is still executing. Please check the task queue. + '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: Rollback group to snapshot + tags: + - RbdGroupSnapshot /api/block/pool/{pool_name}/namespace: get: parameters: -- 2.47.3