From: Tomer Haskalovitch Date: Wed, 15 Jan 2025 09:49:18 +0000 (+0200) Subject: mgr/dashboard: Add additional cli endpoints to align with existing nvmeof cli X-Git-Tag: v20.0.0~293^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=af8e7523ebf0ae566fd941c25ad5e4fe1925526c;p=ceph.git mgr/dashboard: Add additional cli endpoints to align with existing nvmeof cli Added new endpoints to ceph cli and dashboard API to align with cli commands that already exist in existing nvmeof cli. fixes: https://tracker.ceph.com/issues/62705 Signed-off-by: Tomer Haskalovitch --- diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index 762a2bb1c52db..d706e6b3fd17d 100644 --- a/src/pybind/mgr/dashboard/controllers/nvmeof.py +++ b/src/pybind/mgr/dashboard/controllers/nvmeof.py @@ -52,6 +52,82 @@ else: logger.error('Failed to fetch the gateway groups: %s', e) return None + @ReadPermission + @Endpoint('GET', '/version') + @NvmeofCLICommand("nvmeof gw version") + @map_model(model.GatewayVersion) + @handle_nvmeof_error + def version(self, gw_group: Optional[str] = None): + gw_info = NVMeoFClient(gw_group=gw_group).stub.get_gateway_info( + NVMeoFClient.pb2.get_gateway_info_req() + ) + return NVMeoFClient.pb2.gw_version(status=gw_info.status, + error_message=gw_info.error_message, + version=gw_info.version) + + @ReadPermission + @Endpoint('GET', '/log_level') + @NvmeofCLICommand("nvmeof gw get_log_level") + @map_model(model.GatewayLogLevelInfo) + @handle_nvmeof_error + def get_log_level(self, gw_group: Optional[str] = None): + gw_log_level = NVMeoFClient(gw_group=gw_group).stub.get_gateway_log_level( + NVMeoFClient.pb2.get_gateway_log_level_req() + ) + return gw_log_level + + @ReadPermission + @Endpoint('PUT', '/log_level') + @NvmeofCLICommand("nvmeof gw set_log_level") + @map_model(model.RequestStatus) + @handle_nvmeof_error + def set_log_level(self, log_level: str, gw_group: Optional[str] = None): + log_level = log_level.lower() + gw_log_level = NVMeoFClient(gw_group=gw_group).stub.set_gateway_log_level( + NVMeoFClient.pb2.set_gateway_log_level_req(log_level=log_level) + ) + return gw_log_level + + @APIRouter("/nvmeof/spdk", Scope.NVME_OF) + @APIDoc("NVMe-oF SPDK Management API", "NVMe-oF SPDK") + class NVMeoFSpdk(RESTController): + @ReadPermission + @Endpoint('GET', '/log_level') + @NvmeofCLICommand("nvmeof spdk_log_level get") + @map_model(model.SpdkNvmfLogFlagsAndLevelInfo) + @handle_nvmeof_error + def get_spdk_log_level(self, gw_group: Optional[str] = None): + spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.get_spdk_nvmf_log_flags_and_level( + NVMeoFClient.pb2.get_spdk_nvmf_log_flags_and_level_req() + ) + return spdk_log_level + + @ReadPermission + @Endpoint('PUT', '/log_level') + @NvmeofCLICommand("nvmeof spdk_log_level set") + @map_model(model.RequestStatus) + @handle_nvmeof_error + def set_spdk_log_level(self, log_level: Optional[str] = None, + print_level: Optional[str] = None, gw_group: Optional[str] = None): + log_level = log_level.upper() if log_level else None + print_level = print_level.upper() if print_level else None + spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.set_gateway_log_level( + NVMeoFClient.pb2.set_spdk_nvmf_logs_req(log_level=log_level, + print_level=print_level) + ) + return spdk_log_level + + @ReadPermission + @Endpoint('PUT', '/log_level/disable') + @NvmeofCLICommand("nvmeof spdk_log_level disable") + @map_model(model.RequestStatus) + @handle_nvmeof_error + def disable_spdk_log_level(self, gw_group: Optional[str] = None): + spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.disable_spdk_nvmf_logs( + NVMeoFClient.pb2.disable_spdk_nvmf_logs_req() + ) + return spdk_log_level + @APIRouter("/nvmeof/subsystem", Scope.NVME_OF) @APIDoc("NVMe-oF Subsystem Management API", "NVMe-oF Subsystem") class NVMeoFSubsystem(RESTController): diff --git a/src/pybind/mgr/dashboard/model/nvmeof.py b/src/pybind/mgr/dashboard/model/nvmeof.py index 6374c8e5e4ecc..2888f2c65736a 100644 --- a/src/pybind/mgr/dashboard/model/nvmeof.py +++ b/src/pybind/mgr/dashboard/model/nvmeof.py @@ -12,6 +12,23 @@ class GatewayInfo(NamedTuple): spdk_version: Optional[str] = "" +class GatewayVersion(NamedTuple): + version: str + + +class GatewayLogLevelInfo(NamedTuple): + status: int + error_message: str + log_level: int + + +class SpdkNvmfLogFlagsAndLevelInfo(NamedTuple): + status: int + error_message: str + log_level: int + log_print_level: int + + class Subsystem(NamedTuple): nqn: str enable_ha: bool @@ -90,3 +107,8 @@ class Listener(NamedTuple): class Host(NamedTuple): nqn: str + + +class RequestStatus(NamedTuple): + status: int + error_message: str diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index de1b3e8b60e29..2d12a8f2c92c2 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -8272,6 +8272,198 @@ paths: - jwt: [] tags: - NVMe-oF Gateway + /api/nvmeof/gateway/log_level: + get: + parameters: + - allowEmptyValue: true + in: query + name: gw_group + schema: + type: string + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: OK + '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: [] + tags: + - NVMe-oF Gateway + put: + parameters: [] + requestBody: + content: + application/json: + schema: + properties: + gw_group: + type: string + log_level: + type: string + required: + - log_level + 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: [] + tags: + - NVMe-oF Gateway + /api/nvmeof/gateway/version: + get: + parameters: + - allowEmptyValue: true + in: query + name: gw_group + schema: + type: string + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: OK + '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: [] + tags: + - NVMe-oF Gateway + /api/nvmeof/spdk/log_level: + get: + parameters: + - allowEmptyValue: true + in: query + name: gw_group + schema: + type: string + responses: + '200': + content: + application/vnd.ceph.api.v1.0+json: + type: object + description: OK + '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: [] + tags: + - NVMe-oF SPDK + put: + parameters: [] + requestBody: + content: + application/json: + schema: + properties: + gw_group: + type: string + log_level: + type: string + print_level: + 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: [] + tags: + - NVMe-oF SPDK + /api/nvmeof/spdk/log_level/disable: + put: + parameters: [] + requestBody: + content: + application/json: + schema: + properties: + gw_group: + 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: [] + tags: + - NVMe-oF SPDK /api/nvmeof/subsystem: get: parameters: @@ -16192,6 +16384,8 @@ tags: name: NFS-Ganesha - description: NVMe-oF Gateway Management API name: NVMe-oF Gateway +- description: NVMe-oF SPDK Management API + name: NVMe-oF SPDK - description: NVMe-oF Subsystem Management API name: NVMe-oF Subsystem - description: NVMe-oF Subsystem Connection Management API