From 955d7e68ea548c29cb9267894b7221e61f93af17 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Tue, 16 Jun 2026 20:08:29 +0530 Subject: [PATCH] mgr/dashboard: Add "gw refresh_network" cmd Fixes: https://tracker.ceph.com/issues/77442 Signed-off-by: Vallari Agrawal --- .../mgr/dashboard/controllers/nvmeof.py | 37 ++++++++++++ src/pybind/mgr/dashboard/model/nvmeof.py | 7 +++ src/pybind/mgr/dashboard/openapi.yaml | 57 +++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index 557ea546ef1..95065f361bd 100644 --- a/src/pybind/mgr/dashboard/controllers/nvmeof.py +++ b/src/pybind/mgr/dashboard/controllers/nvmeof.py @@ -330,6 +330,43 @@ else: NVMeoFClient.pb2.get_thread_stats_req() ) + @UpdatePermission + @Endpoint('PUT', '/refresh_network') + @NvmeofCLICommand( + "nvmeof gateway refresh_network", model.GwRefreshNetworkStatus, + alias="nvmeof gw refresh_network", + success_message_template=("Refreshed configured network masks for subsystem " + "{nqn} on this gateway: Successful{added}{removed}"), + success_message_map={ + "added": lambda v, _f: f"\nAdded: {', '.join(v)}" if v else "", + "removed": lambda v, _f: f"\nRemoved: {', '.join(v)}" if v else "", + } + ) + @EndpointDoc( + "Re-evaluate subsystem network masks and update auto-listeners for this gateway", + parameters={ + "nqn": Param(str, "NVMeoF subsystem NQN"), + "gw_group": Param(str, "NVMeoF gateway group", True, None), + "server_address": Param(str, "NVMeoF gateway address", True, None), + "traddr": Param(str, "NVMeoF gateway address (deprecated)", True, None), + }, + ) + @convert_to_model(model.GwRefreshNetworkStatus) + @handle_nvmeof_error + def refresh_network(self, nqn: str, gw_group: Optional[str] = None, + server_address: Optional[str] = None, + traddr: Optional[str] = None): + server_address = resolve_nvmeof_server_address( + server_address=server_address, + traddr=traddr + ) + return NVMeoFClient( + gw_group=gw_group, + server_address=server_address + ).stub.gw_refresh_network( + NVMeoFClient.pb2.gw_refresh_network_req(subsystem_nqn=nqn) + ) + @APIRouter("/nvmeof/spdk", Scope.NVME_OF) @APIDoc("NVMe-oF SPDK Management API", "NVMe-oF SPDK") class NVMeoFSpdk(RESTController): diff --git a/src/pybind/mgr/dashboard/model/nvmeof.py b/src/pybind/mgr/dashboard/model/nvmeof.py index f4b7327514e..ec703740042 100644 --- a/src/pybind/mgr/dashboard/model/nvmeof.py +++ b/src/pybind/mgr/dashboard/model/nvmeof.py @@ -369,6 +369,13 @@ class RequestStatus(NamedTuple): error_message: str +class GwRefreshNetworkStatus(NamedTuple): + status: int + error_message: str + added: List[str] + removed: List[str] + + class ListenAdress(NamedTuple): trtype: str adrfam: str diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 2ddd1190b47..1bbd2efbee7 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -12916,6 +12916,63 @@ paths: summary: Set NVMeoF gateway log levels tags: - NVMe-oF Gateway + /api/nvmeof/gateway/refresh_network: + put: + parameters: [] + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + nqn: + description: NVMeoF subsystem NQN + type: string + server_address: + description: NVMeoF gateway address + type: string + traddr: + description: NVMeoF gateway address (deprecated) + type: string + required: + - nqn + type: object + responses: + '200': + content: + application/json: + schema: + type: object + application/vnd.ceph.api.v1.0+json: + schema: + type: object + description: Resource updated. + '202': + content: + application/json: + schema: + type: object + application/vnd.ceph.api.v1.0+json: + schema: + 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: Re-evaluate subsystem network masks and update auto-listeners for this + gateway + tags: + - NVMe-oF Gateway /api/nvmeof/gateway/stats: get: parameters: -- 2.47.3