Skip to content

Commit 9e6960d

Browse files
authored
Merge pull request ceph#64390 from Hezko/nvmeof-cli-missing-cmnds
mgr/dashboard: add missing commands for subsystem: change_key and del…
2 parents 9aedc51 + eaab5a0 commit 9e6960d

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

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

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,46 @@ def delete(self, nqn: str, force: Optional[str] = "false", gw_group: Optional[st
216216
)
217217
)
218218

219+
@EndpointDoc(
220+
"Change subsystem inband authentication key",
221+
parameters={
222+
"nqn": Param(str, "NVMeoF subsystem NQN"),
223+
"dhchap_key": Param(str, "Subsystem DH-HMAC-CHAP key"),
224+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
225+
"traddr": Param(str, "NVMeoF gateway address", True, None),
226+
},
227+
)
228+
@empty_response
229+
@NvmeofCLICommand("nvmeof subsystem change_key", model.RequestStatus)
230+
@convert_to_model(model.RequestStatus)
231+
@handle_nvmeof_error
232+
def change_key(self, nqn: str, dhchap_key: str, gw_group: Optional[str] = None,
233+
traddr: Optional[str] = None):
234+
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_subsystem_key(
235+
NVMeoFClient.pb2.change_subsystem_key_req(
236+
subsystem_nqn=nqn, dhchap_key=dhchap_key
237+
)
238+
)
239+
240+
@EndpointDoc(
241+
"Delete subsystem inband authentication key",
242+
parameters={
243+
"nqn": Param(str, "NVMeoF subsystem NQN"),
244+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
245+
"traddr": Param(str, "NVMeoF gateway address", True, None),
246+
},
247+
)
248+
@empty_response
249+
@NvmeofCLICommand("nvmeof subsystem del_key", model.RequestStatus)
250+
@convert_to_model(model.RequestStatus)
251+
@handle_nvmeof_error
252+
def del_key(self, nqn: str, gw_group: Optional[str] = None, traddr: Optional[str] = None):
253+
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_subsystem_key(
254+
NVMeoFClient.pb2.change_subsystem_key_req(
255+
subsystem_nqn=nqn, dhchap_key=None
256+
)
257+
)
258+
219259
@APIRouter("/nvmeof/subsystem/{nqn}/listener", Scope.NVME_OF)
220260
@APIDoc("NVMe-oF Subsystem Listener Management API", "NVMe-oF Subsystem Listener")
221261
class NVMeoFListener(RESTController):
@@ -896,10 +936,13 @@ def list(
896936
@NvmeofCLICommand("nvmeof host add", model.RequestStatus)
897937
@convert_to_model(model.RequestStatus)
898938
@handle_nvmeof_error
899-
def create(self, nqn: str, host_nqn: str, gw_group: Optional[str] = None,
900-
traddr: Optional[str] = None):
939+
def create(
940+
self, nqn: str, host_nqn: str, dhchap_key: Optional[str] = None,
941+
psk: Optional[str] = None, gw_group: Optional[str] = None, traddr: Optional[str] = None
942+
):
901943
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.add_host(
902-
NVMeoFClient.pb2.add_host_req(subsystem_nqn=nqn, host_nqn=host_nqn)
944+
NVMeoFClient.pb2.add_host_req(subsystem_nqn=nqn, host_nqn=host_nqn,
945+
dhchap_key=dhchap_key, psk=psk)
903946
)
904947

905948
@EndpointDoc(

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8784,12 +8784,16 @@ paths:
87848784
application/json:
87858785
schema:
87868786
properties:
8787+
dhchap_key:
8788+
type: string
87878789
gw_group:
87888790
description: NVMeoF gateway group
87898791
type: string
87908792
host_nqn:
87918793
description: NVMeoF host NQN. Use "*" to allow any host.
87928794
type: string
8795+
psk:
8796+
type: string
87938797
traddr:
87948798
type: string
87958799
required:

0 commit comments

Comments
 (0)