]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add CRUD API endpoints for consistency group snapshots 2/2 66734/head
authorImran Imtiaz <imran.imtiaz@uk.ibm.com>
Wed, 24 Dec 2025 10:14:53 +0000 (10:14 +0000)
committerImran Imtiaz <imran.imtiaz@uk.ibm.com>
Thu, 8 Jan 2026 14:57:34 +0000 (14:57 +0000)
Signed-off-by: Imran Imtiaz <imran.imtiaz@uk.ibm.com>
Fixes: https://tracker.ceph.com/issues/74275
Create a consistency group dashboard API endpoint to:

- rollback
- update

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

index 5cb83900ee8b131bec09bc8015a2ebb94a9dc9af..341360d1a2a9fafc2c62f7195041f1212b75c904 100644 (file)
@@ -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)
index dc17794bb8d43a4dded52f0f552e85572781e22a..cf32d3396b13527a3809e4c423798631f5320b16 100755 (executable)
@@ -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: