Skip to content

Commit 2e82486

Browse files
Tomer HaskalovitchTomer Haskalovitch
authored andcommitted
mgr/dashboard: migrate nvmeof pr ceph#1346 to new cli
Signed-off-by: Tomer Haskalovitch <[email protected]>
1 parent 652d93a commit 2e82486

File tree

2 files changed

+144
-9
lines changed

2 files changed

+144
-9
lines changed

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

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
# pylint: disable=too-many-lines
23
import logging
34
from typing import Any, Dict, List, Optional
45

@@ -100,8 +101,10 @@ class NVMeoFSpdk(RESTController):
100101
@NvmeofCLICommand("nvmeof spdk_log_level get", model.SpdkNvmfLogFlagsAndLevelInfo)
101102
@convert_to_model(model.SpdkNvmfLogFlagsAndLevelInfo)
102103
@handle_nvmeof_error
103-
def get_spdk_log_level(self, all_log_flags: Optional[bool] = None,
104-
gw_group: Optional[str] = None, traddr: Optional[str] = None):
104+
def get_spdk_log_level(
105+
self, all_log_flags: Optional[bool] = None,
106+
gw_group: Optional[str] = None, traddr: Optional[str] = None
107+
):
105108
spdk_log_level = NVMeoFClient(gw_group=gw_group,
106109
traddr=traddr).stub.get_spdk_nvmf_log_flags_and_level(
107110
NVMeoFClient.pb2.get_spdk_nvmf_log_flags_and_level_req(all_log_flags=all_log_flags)
@@ -132,9 +135,11 @@ def set_spdk_log_level(self, log_level: Optional[str] = None,
132135
@NvmeofCLICommand("nvmeof spdk_log_level disable", model.RequestStatus)
133136
@convert_to_model(model.RequestStatus)
134137
@handle_nvmeof_error
135-
def disable_spdk_log_level(self, extra_log_flags: Optional[List[str]] = None,
136-
gw_group: Optional[str] = None,
137-
traddr: Optional[str] = None):
138+
def disable_spdk_log_level(
139+
self, extra_log_flags: Optional[List[str]] = None,
140+
gw_group: Optional[str] = None,
141+
traddr: Optional[str] = None
142+
):
138143
spdk_log_level = NVMeoFClient(gw_group=gw_group,
139144
traddr=traddr).stub.disable_spdk_nvmf_logs(
140145
NVMeoFClient.pb2.disable_spdk_nvmf_logs_req(extra_log_flags=extra_log_flags)
@@ -871,8 +876,10 @@ class NVMeoFHost(RESTController):
871876
@NvmeofCLICommand("nvmeof host list", model.HostsInfo)
872877
@convert_to_model(model.HostsInfo, finalize=_update_hosts)
873878
@handle_nvmeof_error
874-
def list(self, nqn: str, clear_alerts: Optional[bool],
875-
gw_group: Optional[str] = None, traddr: Optional[str] = None):
879+
def list(
880+
self, nqn: str, clear_alerts: Optional[bool],
881+
gw_group: Optional[str] = None, traddr: Optional[str] = None
882+
):
876883
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.list_hosts(
877884
NVMeoFClient.pb2.list_hosts_req(subsystem=nqn, clear_alerts=clear_alerts)
878885
)
@@ -913,6 +920,51 @@ def delete(self, nqn: str, host_nqn: str, gw_group: Optional[str] = None,
913920
NVMeoFClient.pb2.remove_host_req(subsystem_nqn=nqn, host_nqn=host_nqn)
914921
)
915922

923+
@EndpointDoc(
924+
"Change host DH-HMAC-CHAP key",
925+
parameters={
926+
"nqn": Param(str, "NVMeoF subsystem NQN"),
927+
"host_nqn": Param(str, 'NVMeoF host NQN'),
928+
"dhchap_key": Param(str, 'Host DH-HMAC-CHAP key'),
929+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
930+
},
931+
)
932+
@empty_response
933+
@NvmeofCLICommand("nvmeof host change_key", model.RequestStatus)
934+
@convert_to_model(model.RequestStatus)
935+
@handle_nvmeof_error
936+
def change_key(
937+
self, nqn: str, host_nqn: str, dhchap_key: str,
938+
gw_group: Optional[str] = None, traddr: Optional[str] = None
939+
):
940+
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_host_key(
941+
NVMeoFClient.pb2.change_host_key_req(subsystem_nqn=nqn,
942+
host_nqn=host_nqn,
943+
dhchap_key=dhchap_key)
944+
)
945+
946+
@EndpointDoc(
947+
"Delete host DH-HMAC-CHAP key",
948+
parameters={
949+
"nqn": Param(str, "NVMeoF subsystem NQN"),
950+
"host_nqn": Param(str, 'NVMeoF host NQN.'),
951+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
952+
},
953+
)
954+
@empty_response
955+
@NvmeofCLICommand("nvmeof host del_key", model.RequestStatus)
956+
@convert_to_model(model.RequestStatus)
957+
@handle_nvmeof_error
958+
def del_key(
959+
self, nqn: str, host_nqn: str, gw_group: Optional[str] = None,
960+
traddr: Optional[str] = None
961+
):
962+
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.change_host_key(
963+
NVMeoFClient.pb2.change_host_key_req(subsystem_nqn=nqn,
964+
host_nqn=host_nqn,
965+
dhchap_key=None)
966+
)
967+
916968
@APIRouter("/nvmeof/subsystem/{nqn}/connection", Scope.NVME_OF)
917969
@APIDoc("NVMe-oF Subsystem Connection Management API", "NVMe-oF Subsystem Connection")
918970
class NVMeoFConnection(RESTController):

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8396,6 +8396,11 @@ paths:
83968396
/api/nvmeof/spdk/log_level:
83978397
get:
83988398
parameters:
8399+
- allowEmptyValue: true
8400+
in: query
8401+
name: all_log_flags
8402+
schema:
8403+
type: string
83998404
- allowEmptyValue: true
84008405
in: query
84018406
name: gw_group
@@ -8432,6 +8437,8 @@ paths:
84328437
application/json:
84338438
schema:
84348439
properties:
8440+
extra_log_flags:
8441+
type: string
84358442
gw_group:
84368443
type: string
84378444
log_level:
@@ -8473,6 +8480,8 @@ paths:
84738480
application/json:
84748481
schema:
84758482
properties:
8483+
extra_log_flags:
8484+
type: string
84768485
gw_group:
84778486
type: string
84788487
traddr:
@@ -8679,10 +8688,10 @@ paths:
86798688
/api/nvmeof/subsystem/{nqn}/connection:
86808689
get:
86818690
parameters:
8682-
- description: NVMeoF subsystem NQN
8691+
- allowEmptyValue: true
8692+
description: NVMeoF subsystem NQN
86838693
in: path
86848694
name: nqn
8685-
required: true
86868695
schema:
86878696
type: string
86888697
- allowEmptyValue: true
@@ -8725,6 +8734,12 @@ paths:
87258734
required: true
87268735
schema:
87278736
type: string
8737+
- description: Clear any host alert signal after getting its value
8738+
in: query
8739+
name: clear_alerts
8740+
required: true
8741+
schema:
8742+
type: boolean
87288743
- allowEmptyValue: true
87298744
description: NVMeoF gateway group
87308745
in: query
@@ -9085,6 +9100,9 @@ paths:
90859100
default: false
90869101
description: Create RBD image
90879102
type: boolean
9103+
disable_auto_resize:
9104+
default: false
9105+
type: integer
90889106
force:
90899107
default: false
90909108
description: Force create namespace even it image is used by other
@@ -9110,6 +9128,9 @@ paths:
91109128
default: rbd
91119129
description: RBD pool name
91129130
type: string
9131+
read_only:
9132+
default: false
9133+
type: boolean
91139134
size:
91149135
default: 1024
91159136
description: RBD image size
@@ -9336,6 +9357,10 @@ paths:
93369357
application/json:
93379358
schema:
93389359
properties:
9360+
force:
9361+
description: Allow adding the host to the namespace even if the
9362+
host has no access to the subsystem
9363+
type: boolean
93399364
gw_group:
93409365
description: NVMeoF gateway group
93419366
type: string
@@ -9701,6 +9726,64 @@ paths:
97019726
summary: resize the specified NVMeoF namespace
97029727
tags:
97039728
- NVMe-oF Subsystem Namespace
9729+
/api/nvmeof/subsystem/{nqn}/namespace/{nsid}/set_auto_resize:
9730+
put:
9731+
parameters:
9732+
- description: NVMeoF subsystem NQN
9733+
in: path
9734+
name: nqn
9735+
required: true
9736+
schema:
9737+
type: string
9738+
- description: NVMeoF Namespace ID
9739+
in: path
9740+
name: nsid
9741+
required: true
9742+
schema:
9743+
type: string
9744+
requestBody:
9745+
content:
9746+
application/json:
9747+
schema:
9748+
properties:
9749+
auto_resize_enabled:
9750+
description: Enable or disable auto resize of namespace when RBD
9751+
image is resized
9752+
type: boolean
9753+
gw_group:
9754+
description: NVMeoF gateway group
9755+
type: string
9756+
traddr:
9757+
description: NVMeoF gateway address
9758+
type: string
9759+
required:
9760+
- auto_resize_enabled
9761+
type: object
9762+
responses:
9763+
'200':
9764+
content:
9765+
application/vnd.ceph.api.v1.0+json:
9766+
type: object
9767+
description: Resource updated.
9768+
'202':
9769+
content:
9770+
application/vnd.ceph.api.v1.0+json:
9771+
type: object
9772+
description: Operation is still executing. Please check the task queue.
9773+
'400':
9774+
description: Operation exception. Please check the response body for details.
9775+
'401':
9776+
description: Unauthenticated access. Please login first.
9777+
'403':
9778+
description: Unauthorized access. Please check your permissions.
9779+
'500':
9780+
description: Unexpected error. Please check the response body for the stack
9781+
trace.
9782+
security:
9783+
- jwt: []
9784+
summary: Enable or disable namespace auto resize when RBD image is resized
9785+
tags:
9786+
- NVMe-oF Subsystem Namespace
97049787
/api/nvmeof/subsystem/{nqn}/namespace/{nsid}/set_qos:
97059788
put:
97069789
parameters:

0 commit comments

Comments
 (0)