Skip to content

Commit af8e752

Browse files
Tomer HaskalovitchHezko
authored andcommitted
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 <[email protected]>
1 parent 6e0ae19 commit af8e752

File tree

3 files changed

+292
-0
lines changed

3 files changed

+292
-0
lines changed

src/pybind/mgr/dashboard/controllers/nvmeof.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,82 @@ def group(self):
5252
logger.error('Failed to fetch the gateway groups: %s', e)
5353
return None
5454

55+
@ReadPermission
56+
@Endpoint('GET', '/version')
57+
@NvmeofCLICommand("nvmeof gw version")
58+
@map_model(model.GatewayVersion)
59+
@handle_nvmeof_error
60+
def version(self, gw_group: Optional[str] = None):
61+
gw_info = NVMeoFClient(gw_group=gw_group).stub.get_gateway_info(
62+
NVMeoFClient.pb2.get_gateway_info_req()
63+
)
64+
return NVMeoFClient.pb2.gw_version(status=gw_info.status,
65+
error_message=gw_info.error_message,
66+
version=gw_info.version)
67+
68+
@ReadPermission
69+
@Endpoint('GET', '/log_level')
70+
@NvmeofCLICommand("nvmeof gw get_log_level")
71+
@map_model(model.GatewayLogLevelInfo)
72+
@handle_nvmeof_error
73+
def get_log_level(self, gw_group: Optional[str] = None):
74+
gw_log_level = NVMeoFClient(gw_group=gw_group).stub.get_gateway_log_level(
75+
NVMeoFClient.pb2.get_gateway_log_level_req()
76+
)
77+
return gw_log_level
78+
79+
@ReadPermission
80+
@Endpoint('PUT', '/log_level')
81+
@NvmeofCLICommand("nvmeof gw set_log_level")
82+
@map_model(model.RequestStatus)
83+
@handle_nvmeof_error
84+
def set_log_level(self, log_level: str, gw_group: Optional[str] = None):
85+
log_level = log_level.lower()
86+
gw_log_level = NVMeoFClient(gw_group=gw_group).stub.set_gateway_log_level(
87+
NVMeoFClient.pb2.set_gateway_log_level_req(log_level=log_level)
88+
)
89+
return gw_log_level
90+
91+
@APIRouter("/nvmeof/spdk", Scope.NVME_OF)
92+
@APIDoc("NVMe-oF SPDK Management API", "NVMe-oF SPDK")
93+
class NVMeoFSpdk(RESTController):
94+
@ReadPermission
95+
@Endpoint('GET', '/log_level')
96+
@NvmeofCLICommand("nvmeof spdk_log_level get")
97+
@map_model(model.SpdkNvmfLogFlagsAndLevelInfo)
98+
@handle_nvmeof_error
99+
def get_spdk_log_level(self, gw_group: Optional[str] = None):
100+
spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.get_spdk_nvmf_log_flags_and_level(
101+
NVMeoFClient.pb2.get_spdk_nvmf_log_flags_and_level_req()
102+
)
103+
return spdk_log_level
104+
105+
@ReadPermission
106+
@Endpoint('PUT', '/log_level')
107+
@NvmeofCLICommand("nvmeof spdk_log_level set")
108+
@map_model(model.RequestStatus)
109+
@handle_nvmeof_error
110+
def set_spdk_log_level(self, log_level: Optional[str] = None,
111+
print_level: Optional[str] = None, gw_group: Optional[str] = None):
112+
log_level = log_level.upper() if log_level else None
113+
print_level = print_level.upper() if print_level else None
114+
spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.set_gateway_log_level(
115+
NVMeoFClient.pb2.set_spdk_nvmf_logs_req(log_level=log_level,
116+
print_level=print_level)
117+
)
118+
return spdk_log_level
119+
120+
@ReadPermission
121+
@Endpoint('PUT', '/log_level/disable')
122+
@NvmeofCLICommand("nvmeof spdk_log_level disable")
123+
@map_model(model.RequestStatus)
124+
@handle_nvmeof_error
125+
def disable_spdk_log_level(self, gw_group: Optional[str] = None):
126+
spdk_log_level = NVMeoFClient(gw_group=gw_group).stub.disable_spdk_nvmf_logs(
127+
NVMeoFClient.pb2.disable_spdk_nvmf_logs_req()
128+
)
129+
return spdk_log_level
130+
55131
@APIRouter("/nvmeof/subsystem", Scope.NVME_OF)
56132
@APIDoc("NVMe-oF Subsystem Management API", "NVMe-oF Subsystem")
57133
class NVMeoFSubsystem(RESTController):

src/pybind/mgr/dashboard/model/nvmeof.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ class GatewayInfo(NamedTuple):
1212
spdk_version: Optional[str] = ""
1313

1414

15+
class GatewayVersion(NamedTuple):
16+
version: str
17+
18+
19+
class GatewayLogLevelInfo(NamedTuple):
20+
status: int
21+
error_message: str
22+
log_level: int
23+
24+
25+
class SpdkNvmfLogFlagsAndLevelInfo(NamedTuple):
26+
status: int
27+
error_message: str
28+
log_level: int
29+
log_print_level: int
30+
31+
1532
class Subsystem(NamedTuple):
1633
nqn: str
1734
enable_ha: bool
@@ -90,3 +107,8 @@ class Listener(NamedTuple):
90107

91108
class Host(NamedTuple):
92109
nqn: str
110+
111+
112+
class RequestStatus(NamedTuple):
113+
status: int
114+
error_message: str

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8272,6 +8272,198 @@ paths:
82728272
- jwt: []
82738273
tags:
82748274
- NVMe-oF Gateway
8275+
/api/nvmeof/gateway/log_level:
8276+
get:
8277+
parameters:
8278+
- allowEmptyValue: true
8279+
in: query
8280+
name: gw_group
8281+
schema:
8282+
type: string
8283+
responses:
8284+
'200':
8285+
content:
8286+
application/vnd.ceph.api.v1.0+json:
8287+
type: object
8288+
description: OK
8289+
'400':
8290+
description: Operation exception. Please check the response body for details.
8291+
'401':
8292+
description: Unauthenticated access. Please login first.
8293+
'403':
8294+
description: Unauthorized access. Please check your permissions.
8295+
'500':
8296+
description: Unexpected error. Please check the response body for the stack
8297+
trace.
8298+
security:
8299+
- jwt: []
8300+
tags:
8301+
- NVMe-oF Gateway
8302+
put:
8303+
parameters: []
8304+
requestBody:
8305+
content:
8306+
application/json:
8307+
schema:
8308+
properties:
8309+
gw_group:
8310+
type: string
8311+
log_level:
8312+
type: string
8313+
required:
8314+
- log_level
8315+
type: object
8316+
responses:
8317+
'200':
8318+
content:
8319+
application/vnd.ceph.api.v1.0+json:
8320+
type: object
8321+
description: Resource updated.
8322+
'202':
8323+
content:
8324+
application/vnd.ceph.api.v1.0+json:
8325+
type: object
8326+
description: Operation is still executing. Please check the task queue.
8327+
'400':
8328+
description: Operation exception. Please check the response body for details.
8329+
'401':
8330+
description: Unauthenticated access. Please login first.
8331+
'403':
8332+
description: Unauthorized access. Please check your permissions.
8333+
'500':
8334+
description: Unexpected error. Please check the response body for the stack
8335+
trace.
8336+
security:
8337+
- jwt: []
8338+
tags:
8339+
- NVMe-oF Gateway
8340+
/api/nvmeof/gateway/version:
8341+
get:
8342+
parameters:
8343+
- allowEmptyValue: true
8344+
in: query
8345+
name: gw_group
8346+
schema:
8347+
type: string
8348+
responses:
8349+
'200':
8350+
content:
8351+
application/vnd.ceph.api.v1.0+json:
8352+
type: object
8353+
description: OK
8354+
'400':
8355+
description: Operation exception. Please check the response body for details.
8356+
'401':
8357+
description: Unauthenticated access. Please login first.
8358+
'403':
8359+
description: Unauthorized access. Please check your permissions.
8360+
'500':
8361+
description: Unexpected error. Please check the response body for the stack
8362+
trace.
8363+
security:
8364+
- jwt: []
8365+
tags:
8366+
- NVMe-oF Gateway
8367+
/api/nvmeof/spdk/log_level:
8368+
get:
8369+
parameters:
8370+
- allowEmptyValue: true
8371+
in: query
8372+
name: gw_group
8373+
schema:
8374+
type: string
8375+
responses:
8376+
'200':
8377+
content:
8378+
application/vnd.ceph.api.v1.0+json:
8379+
type: object
8380+
description: OK
8381+
'400':
8382+
description: Operation exception. Please check the response body for details.
8383+
'401':
8384+
description: Unauthenticated access. Please login first.
8385+
'403':
8386+
description: Unauthorized access. Please check your permissions.
8387+
'500':
8388+
description: Unexpected error. Please check the response body for the stack
8389+
trace.
8390+
security:
8391+
- jwt: []
8392+
tags:
8393+
- NVMe-oF SPDK
8394+
put:
8395+
parameters: []
8396+
requestBody:
8397+
content:
8398+
application/json:
8399+
schema:
8400+
properties:
8401+
gw_group:
8402+
type: string
8403+
log_level:
8404+
type: string
8405+
print_level:
8406+
type: string
8407+
type: object
8408+
responses:
8409+
'200':
8410+
content:
8411+
application/vnd.ceph.api.v1.0+json:
8412+
type: object
8413+
description: Resource updated.
8414+
'202':
8415+
content:
8416+
application/vnd.ceph.api.v1.0+json:
8417+
type: object
8418+
description: Operation is still executing. Please check the task queue.
8419+
'400':
8420+
description: Operation exception. Please check the response body for details.
8421+
'401':
8422+
description: Unauthenticated access. Please login first.
8423+
'403':
8424+
description: Unauthorized access. Please check your permissions.
8425+
'500':
8426+
description: Unexpected error. Please check the response body for the stack
8427+
trace.
8428+
security:
8429+
- jwt: []
8430+
tags:
8431+
- NVMe-oF SPDK
8432+
/api/nvmeof/spdk/log_level/disable:
8433+
put:
8434+
parameters: []
8435+
requestBody:
8436+
content:
8437+
application/json:
8438+
schema:
8439+
properties:
8440+
gw_group:
8441+
type: string
8442+
type: object
8443+
responses:
8444+
'200':
8445+
content:
8446+
application/vnd.ceph.api.v1.0+json:
8447+
type: object
8448+
description: Resource updated.
8449+
'202':
8450+
content:
8451+
application/vnd.ceph.api.v1.0+json:
8452+
type: object
8453+
description: Operation is still executing. Please check the task queue.
8454+
'400':
8455+
description: Operation exception. Please check the response body for details.
8456+
'401':
8457+
description: Unauthenticated access. Please login first.
8458+
'403':
8459+
description: Unauthorized access. Please check your permissions.
8460+
'500':
8461+
description: Unexpected error. Please check the response body for the stack
8462+
trace.
8463+
security:
8464+
- jwt: []
8465+
tags:
8466+
- NVMe-oF SPDK
82758467
/api/nvmeof/subsystem:
82768468
get:
82778469
parameters:
@@ -16192,6 +16384,8 @@ tags:
1619216384
name: NFS-Ganesha
1619316385
- description: NVMe-oF Gateway Management API
1619416386
name: NVMe-oF Gateway
16387+
- description: NVMe-oF SPDK Management API
16388+
name: NVMe-oF SPDK
1619516389
- description: NVMe-oF Subsystem Management API
1619616390
name: NVMe-oF Subsystem
1619716391
- description: NVMe-oF Subsystem Connection Management API

0 commit comments

Comments
 (0)