From: Tomer Haskalovitch Date: Thu, 26 Jun 2025 10:25:53 +0000 (+0300) Subject: mgr/dashboard: migrate nvmeof pr #1346 to new cli X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=08a0f0dfb49f8298320e980ffeac3a43ec888cf4;p=ceph.git mgr/dashboard: migrate nvmeof pr #1346 to new cli Signed-off-by: Tomer Haskalovitch (cherry picked from commit 2e82486884b67ac6b7fd553a2ab7283f8b8cb096) --- diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index 921a1a418b233..9ce2dc92df886 100644 --- a/src/pybind/mgr/dashboard/controllers/nvmeof.py +++ b/src/pybind/mgr/dashboard/controllers/nvmeof.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# pylint: disable=too-many-lines import logging from typing import Any, Dict, List, Optional @@ -100,8 +101,10 @@ else: @NvmeofCLICommand("nvmeof spdk_log_level get", model.SpdkNvmfLogFlagsAndLevelInfo) @convert_to_model(model.SpdkNvmfLogFlagsAndLevelInfo) @handle_nvmeof_error - def get_spdk_log_level(self, all_log_flags: Optional[bool] = None, - gw_group: Optional[str] = None, traddr: Optional[str] = None): + def get_spdk_log_level( + self, all_log_flags: Optional[bool] = None, + gw_group: Optional[str] = None, traddr: Optional[str] = None + ): spdk_log_level = NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.get_spdk_nvmf_log_flags_and_level( NVMeoFClient.pb2.get_spdk_nvmf_log_flags_and_level_req(all_log_flags=all_log_flags) @@ -132,9 +135,11 @@ else: @NvmeofCLICommand("nvmeof spdk_log_level disable", model.RequestStatus) @convert_to_model(model.RequestStatus) @handle_nvmeof_error - def disable_spdk_log_level(self, extra_log_flags: Optional[List[str]] = None, - gw_group: Optional[str] = None, - traddr: Optional[str] = None): + def disable_spdk_log_level( + self, extra_log_flags: Optional[List[str]] = None, + gw_group: Optional[str] = None, + traddr: Optional[str] = None + ): spdk_log_level = NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.disable_spdk_nvmf_logs( NVMeoFClient.pb2.disable_spdk_nvmf_logs_req(extra_log_flags=extra_log_flags) @@ -871,8 +876,10 @@ else: @NvmeofCLICommand("nvmeof host list", model.HostsInfo) @convert_to_model(model.HostsInfo, finalize=_update_hosts) @handle_nvmeof_error - def list(self, nqn: str, clear_alerts: Optional[bool], - gw_group: Optional[str] = None, traddr: Optional[str] = None): + def list( + self, nqn: str, clear_alerts: Optional[bool], + gw_group: Optional[str] = None, traddr: Optional[str] = None + ): return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.list_hosts( NVMeoFClient.pb2.list_hosts_req(subsystem=nqn, clear_alerts=clear_alerts) ) @@ -913,6 +920,51 @@ else: NVMeoFClient.pb2.remove_host_req(subsystem_nqn=nqn, host_nqn=host_nqn) ) + @EndpointDoc( + "Change host DH-HMAC-CHAP key", + parameters={ + "nqn": Param(str, "NVMeoF subsystem NQN"), + "host_nqn": Param(str, 'NVMeoF host NQN'), + "dhchap_key": Param(str, 'Host DH-HMAC-CHAP key'), + "gw_group": Param(str, "NVMeoF gateway group", True, None), + }, + ) + @empty_response + @NvmeofCLICommand("nvmeof host change_key", model.RequestStatus) + @convert_to_model(model.RequestStatus) + @handle_nvmeof_error + def change_key( + self, nqn: str, host_nqn: str, dhchap_key: str, + gw_group: Optional[str] = None, traddr: Optional[str] = None + ): + return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_host_key( + NVMeoFClient.pb2.change_host_key_req(subsystem_nqn=nqn, + host_nqn=host_nqn, + dhchap_key=dhchap_key) + ) + + @EndpointDoc( + "Delete host DH-HMAC-CHAP key", + parameters={ + "nqn": Param(str, "NVMeoF subsystem NQN"), + "host_nqn": Param(str, 'NVMeoF host NQN.'), + "gw_group": Param(str, "NVMeoF gateway group", True, None), + }, + ) + @empty_response + @NvmeofCLICommand("nvmeof host del_key", model.RequestStatus) + @convert_to_model(model.RequestStatus) + @handle_nvmeof_error + def del_key( + self, nqn: str, host_nqn: str, gw_group: Optional[str] = None, + traddr: Optional[str] = None + ): + return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_host_key( + NVMeoFClient.pb2.change_host_key_req(subsystem_nqn=nqn, + host_nqn=host_nqn, + dhchap_key=None) + ) + @APIRouter("/nvmeof/subsystem/{nqn}/connection", Scope.NVME_OF) @APIDoc("NVMe-oF Subsystem Connection Management API", "NVMe-oF Subsystem Connection") class NVMeoFConnection(RESTController): diff --git a/src/pybind/mgr/dashboard/model/nvmeof.py b/src/pybind/mgr/dashboard/model/nvmeof.py index 58bb3b1e9e175..f756c83923d29 100644 --- a/src/pybind/mgr/dashboard/model/nvmeof.py +++ b/src/pybind/mgr/dashboard/model/nvmeof.py @@ -128,7 +128,6 @@ class Namespace(NamedTuple): read_only: Optional[bool] - class NamespaceList(NamedTuple): status: int error_message: str diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index df071682e26fe..920c5d6aa8a92 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -8396,6 +8396,11 @@ paths: /api/nvmeof/spdk/log_level: get: parameters: + - allowEmptyValue: true + in: query + name: all_log_flags + schema: + type: string - allowEmptyValue: true in: query name: gw_group @@ -8432,6 +8437,8 @@ paths: application/json: schema: properties: + extra_log_flags: + type: string gw_group: type: string log_level: @@ -8473,6 +8480,8 @@ paths: application/json: schema: properties: + extra_log_flags: + type: string gw_group: type: string traddr: @@ -8679,10 +8688,10 @@ paths: /api/nvmeof/subsystem/{nqn}/connection: get: parameters: - - description: NVMeoF subsystem NQN + - allowEmptyValue: true + description: NVMeoF subsystem NQN in: path name: nqn - required: true schema: type: string - allowEmptyValue: true @@ -8725,6 +8734,12 @@ paths: required: true schema: type: string + - description: Clear any host alert signal after getting its value + in: query + name: clear_alerts + required: true + schema: + type: boolean - allowEmptyValue: true description: NVMeoF gateway group in: query @@ -9085,6 +9100,9 @@ paths: default: true description: Create RBD image type: boolean + disable_auto_resize: + default: false + type: integer force: default: false description: Force create namespace even it image is used by other @@ -9110,6 +9128,9 @@ paths: default: rbd description: RBD pool name type: string + read_only: + default: false + type: boolean size: default: 1024 description: RBD image size @@ -9316,6 +9337,240 @@ paths: summary: Update an existing NVMeoF namespace tags: - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/add_host: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + force: + description: Allow adding the host to the namespace even if the + host has no access to the subsystem + type: boolean + gw_group: + description: NVMeoF gateway group + type: string + host_nqn: + description: NVMeoF host NQN. Use "*" to allow any host. + type: string + traddr: + description: NVMeoF gateway address + type: string + required: + - host_nqn + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: Adds a host to the specified NVMeoF namespace + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/change_load_balancing_group: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + load_balancing_group: + description: Load balancing group + type: integer + traddr: + description: NVMeoF gateway address + type: string + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: set the load balancing group for specified NVMeoF namespace + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/change_visibility: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + auto_visible: + description: True if visible to all hosts + type: boolean + force: + default: false + type: boolean + gw_group: + description: NVMeoF gateway group + type: string + traddr: + description: NVMeoF gateway address + type: string + required: + - auto_visible + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: changes the visibility of the specified NVMeoF namespace to all or + selected hosts + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/del_host: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + host_nqn: + description: NVMeoF host NQN. Use "*" to allow any host. + type: string + traddr: + description: NVMeoF gateway address + type: string + required: + - host_nqn + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: Removes a host from the specified NVMeoF namespace + tags: + - NVMe-oF Subsystem Namespace /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/io_stats: get: parameters: @@ -9362,6 +9617,299 @@ paths: summary: Get IO stats from specified NVMeoF namespace tags: - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/refresh_size: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + traddr: + description: NVMeoF gateway address + type: string + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: refresh the specified NVMeoF namespace to current RBD image size + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/resize: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + rbd_image_size: + description: RBD image size + type: integer + traddr: + description: NVMeoF gateway address + type: string + required: + - rbd_image_size + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: resize the specified NVMeoF namespace + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/set_auto_resize: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + auto_resize_enabled: + description: Enable or disable auto resize of namespace when RBD + image is resized + type: boolean + gw_group: + description: NVMeoF gateway group + type: string + traddr: + description: NVMeoF gateway address + type: string + required: + - auto_resize_enabled + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: Enable or disable namespace auto resize when RBD image is resized + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/set_qos: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + force: + default: false + description: Set QOS limits even if they were changed by RBD + type: boolean + gw_group: + description: NVMeoF gateway group + type: string + r_mbytes_per_second: + description: Read MB/s + type: integer + rw_ios_per_second: + description: Read/Write IOPS + type: integer + rw_mbytes_per_second: + description: Read/Write MB/s + type: integer + traddr: + description: NVMeoF gateway address + type: string + w_mbytes_per_second: + description: Write MB/s + type: integer + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: set QOS for specified NVMeoF namespace + tags: + - NVMe-oF Subsystem Namespace + /api/nvmeof/subsystem/{nqn}/namespace/{nsid}/set_rbd_trash_image: + put: + parameters: + - description: NVMeoF subsystem NQN + in: path + name: nqn + required: true + schema: + type: string + - description: NVMeoF Namespace ID + in: path + name: nsid + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + gw_group: + description: NVMeoF gateway group + type: string + rbd_trash_image_on_delete: + description: True if active + type: boolean + traddr: + description: NVMeoF gateway address + type: string + required: + - rbd_trash_image_on_delete + type: object + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + 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: changes the trash image on delete of the specified NVMeoF namespace + to all or selected hosts + tags: + - NVMe-oF Subsystem Namespace /api/osd: get: parameters: