]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: add multiple ceph users deletion
authorPedro Gonzalez Gomez <pegonzal@ibm.com>
Wed, 27 Aug 2025 14:41:41 +0000 (16:41 +0200)
committerJon <jonathan.bailey1@ibm.com>
Fri, 3 Oct 2025 13:31:28 +0000 (14:31 +0100)
Fixes: https://tracker.ceph.com/issues/72752
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@ibm.com>
(cherry picked from commit 14ca16576d16de49c07725fb4b0feb112c8a1a43)

src/pybind/mgr/dashboard/controllers/ceph_users.py
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/data-gateway.service.ts
src/pybind/mgr/dashboard/openapi.yaml

index c956f1757e28f8c5a0cdfab1276ab593ffecb2fb..4ac3eda8a3c2bbbe78aff2fdccbf0ccf6097e67c 100644 (file)
@@ -70,13 +70,16 @@ class CephUserEndpoints:
         return f"Successfully created user '{user_entity}'"
 
     @staticmethod
-    def user_delete(_, user_entity: str):
+    def user_delete(_, user_entities: str):
         """
-        Delete a ceph user and it's defined capabilities.
+        Delete one or more ceph users and their defined capabilities.
+        user_entities: comma-separated string of users to delete
         """
-        logger.debug("Sending command 'auth del' of entity '%s'", user_entity)
-        CephUserEndpoints._run_auth_command('auth del', entity=user_entity)
-        return f"Successfully deleted user '{user_entity}'"
+        users = user_entities.split(',')
+        for user in users:
+            logger.debug("Sending command 'auth del' of entity '%s'", user)
+            CephUserEndpoints._run_auth_command('auth del', entity=user)
+        return f"Successfully deleted user(s) '{user_entities}'"
 
     @staticmethod
     def export(_, entities: List[str]):
@@ -209,7 +212,7 @@ edit_form = Form(path='/cluster/user/edit',
     ),
     delete=CRUDCollectionMethod(
         func=CephUserEndpoints.user_delete,
-        doc=EndpointDoc("Delete Ceph User",
+        doc=EndpointDoc("Delete one or more Ceph Users",
                         parameters={
                             "user_entity": Param(str, "Entity to delete")
                         })
index 08f2db4fcc7cd2910bf65477120cee222dda85d7..5640b5f5364de92c041932bac8847d6430a5681d 100644 (file)
@@ -118,15 +118,18 @@ export class CRUDTableComponent implements OnInit {
   }
 
   delete() {
-    const selectedKey = this.selection.first()[this.meta.columnKey];
+    let selectedKeys: string[] = [];
+    this.selection.selected.forEach((item: any) => {
+      selectedKeys.push(item[this.meta.columnKey]);
+    });
     this.modalRef = this.modalService.show(DeleteConfirmationModalComponent, {
       itemDescription: $localize`${this.meta.resource}`,
-      itemNames: [selectedKey],
+      itemNames: selectedKeys,
       submitAction: () => {
         this.taskWrapper
           .wrapTaskAroundCall({
-            task: new FinishedTask('crud-component/id', selectedKey),
-            call: this.dataGatewayService.delete(this.resource, selectedKey)
+            task: new FinishedTask('crud-component/id', selectedKeys),
+            call: this.dataGatewayService.delete(this.resource, selectedKeys)
           })
           .subscribe({
             error: () => {
index c4a223e31b3e982d2862a31d2f6df4cb7d8da5f3..c12c9bfaab0c92349ac27f346ac17accb84949d0 100644 (file)
@@ -1,4 +1,4 @@
-import { HttpClient, HttpParams } from '@angular/common/http';
+import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 
 import { Observable } from 'rxjs';
@@ -36,10 +36,12 @@ export class DataGatewayService {
     });
   }
 
-  delete(dataPath: string, key: string): Observable<any> {
+  delete(dataPath: string, key: string | string[]): Observable<HttpResponse<void>> {
     const { url, version } = this.getUrlAndVersion(dataPath);
 
-    return this.http.delete<any>(`${url}/${key}`, {
+    const keyPath = Array.isArray(key) ? key.join(',') : key;
+
+    return this.http.delete<void>(`${url}/${keyPath}`, {
       headers: { Accept: `application/vnd.ceph.api.v${version}+json` },
       observe: 'response'
     });
index 987b8c4d102a64f79792fbcad6b80b1756a845a5..2ac061cf2eb92562bcfbc4a69f2fac3c2491279d 100755 (executable)
@@ -3951,14 +3951,14 @@ paths:
       summary: Export Ceph Users
       tags:
       - Cluster
-  /api/cluster/user/{user_entity}:
+  /api/cluster/user/{user_entities}:
     delete:
-      description: "\n        Delete a ceph user and it's defined capabilities.\n\
-        \        "
+      description: "\n        Delete one or more ceph users and their defined capabilities.\n\
+        \        user_entities: comma-separated string of users to delete\n      \
+        \  "
       parameters:
-      - description: Entity to delete
-        in: path
-        name: user_entity
+      - in: path
+        name: user_entities
         required: true
         schema:
           type: string
@@ -3984,7 +3984,7 @@ paths:
             trace.
       security:
       - jwt: []
-      summary: Delete Ceph User
+      summary: Delete one or more Ceph Users
       tags:
       - Cluster
   /api/cluster_conf: