]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add additional cli endpoints to align with existing nvmeof cli 61998/head
authorTomer Haskalovitch <il033030@Tomers-MBP.lan>
Wed, 15 Jan 2025 09:49:18 +0000 (11:49 +0200)
committerTomer Haskalovitch <il033030@Tomers-MBP.lan>
Tue, 25 Feb 2025 09:06:31 +0000 (11:06 +0200)
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 <il033030@Tomers-MBP.lan>
(cherry picked from commit af8e7523ebf0ae566fd941c25ad5e4fe1925526c)

src/pybind/mgr/dashboard/controllers/nvmeof.py
src/pybind/mgr/dashboard/model/nvmeof.py
src/pybind/mgr/dashboard/openapi.yaml

index f199867943d14c9a7e4c1d027839867cd7e4dae9..27b7a69cec206c00cd1677eb2bef012f2c11d4a6 100644 (file)
@@ -50,6 +50,76 @@ else:
                 logger.error('Failed to fetch the gateway groups: %s', e)
                 return None
 
+        @ReadPermission
+        @Endpoint('GET', '/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')
+        @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')
+        @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')
+        @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')
+        @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')
+        @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):
index 6374c8e5e4eccef98f22db8e56051cdf4c7dcd7d..2888f2c65736a840b0bcba497429598fab9a0401 100644 (file)
@@ -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
index e6a577e8d3b0a36f553cb3d129f5918de57cd9ea..8d983a8784a2f787e327d0e791d6c3843f37bd6c 100644 (file)
@@ -7871,6 +7871,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:
@@ -14999,6 +15191,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