From: Pedro Gonzalez Gomez Date: Wed, 27 Aug 2025 14:41:41 +0000 (+0200) Subject: mgr/dashboard: add multiple ceph users deletion X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=14ca16576d16de49c07725fb4b0feb112c8a1a43;p=ceph.git mgr/dashboard: add multiple ceph users deletion Fixes: https://tracker.ceph.com/issues/72752 Signed-off-by: Pedro Gonzalez Gomez --- diff --git a/src/pybind/mgr/dashboard/controllers/ceph_users.py b/src/pybind/mgr/dashboard/controllers/ceph_users.py index c956f1757e28..4ac3eda8a3c2 100644 --- a/src/pybind/mgr/dashboard/controllers/ceph_users.py +++ b/src/pybind/mgr/dashboard/controllers/ceph_users.py @@ -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") }) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts index 08f2db4fcc7c..5640b5f5364d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts @@ -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: () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/data-gateway.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/data-gateway.service.ts index c4a223e31b3e..c12c9bfaab0c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/data-gateway.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/data-gateway.service.ts @@ -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 { + delete(dataPath: string, key: string | string[]): Observable> { const { url, version } = this.getUrlAndVersion(dataPath); - return this.http.delete(`${url}/${key}`, { + const keyPath = Array.isArray(key) ? key.join(',') : key; + + return this.http.delete(`${url}/${keyPath}`, { headers: { Accept: `application/vnd.ceph.api.v${version}+json` }, observe: 'response' }); diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 4752bc7b3ae2..bb7e52e3387d 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -3919,14 +3919,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 @@ -3952,7 +3952,7 @@ paths: trace. security: - jwt: [] - summary: Delete Ceph User + summary: Delete one or more Ceph Users tags: - Cluster /api/cluster_conf: