Skip to content

Commit 485cb05

Browse files
committed
mgr/dashboard: add gw_groups to all nvmeof endpoints
This was missed in the previous implementation Signed-off-by: Nizamudeen A <[email protected]>
1 parent d7c144c commit 485cb05

File tree

2 files changed

+127
-28
lines changed

2 files changed

+127
-28
lines changed

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

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def list(self, gw_group: Optional[str] = None):
6363

6464
@EndpointDoc(
6565
"Get information from a specific NVMeoF subsystem",
66-
parameters={"nqn": Param(str, "NVMeoF subsystem NQN")},
66+
parameters={
67+
"nqn": Param(str, "NVMeoF subsystem NQN"),
68+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
69+
},
6770
)
6871
@map_model(model.Subsystem, first="subsystems")
6972
@handle_nvmeof_error
@@ -78,6 +81,7 @@ def get(self, nqn: str, gw_group: Optional[str] = None):
7881
"nqn": Param(str, "NVMeoF subsystem NQN"),
7982
"max_namespaces": Param(int, "Maximum number of namespaces", True, 1024),
8083
"enable_ha": Param(bool, "Enable high availability"),
84+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
8185
},
8286
)
8387
@empty_response
@@ -95,6 +99,7 @@ def create(self, nqn: str, enable_ha: bool, max_namespaces: int = 1024,
9599
parameters={
96100
"nqn": Param(str, "NVMeoF subsystem NQN"),
97101
"force": Param(bool, "Force delete", "false"),
102+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
98103
},
99104
)
100105
@empty_response
@@ -111,12 +116,15 @@ def delete(self, nqn: str, force: Optional[str] = "false", gw_group: Optional[st
111116
class NVMeoFListener(RESTController):
112117
@EndpointDoc(
113118
"List all NVMeoF listeners",
114-
parameters={"nqn": Param(str, "NVMeoF subsystem NQN")},
119+
parameters={
120+
"nqn": Param(str, "NVMeoF subsystem NQN"),
121+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
122+
},
115123
)
116124
@map_collection(model.Listener, pick="listeners")
117125
@handle_nvmeof_error
118-
def list(self, nqn: str):
119-
return NVMeoFClient().stub.list_listeners(
126+
def list(self, nqn: str, gw_group: Optional[str] = None):
127+
return NVMeoFClient(gw_group=gw_group).stub.list_listeners(
120128
NVMeoFClient.pb2.list_listeners_req(subsystem=nqn)
121129
)
122130

@@ -128,6 +136,7 @@ def list(self, nqn: str):
128136
"traddr": Param(str, "NVMeoF transport address"),
129137
"trsvcid": Param(int, "NVMeoF transport service port", True, 4420),
130138
"adrfam": Param(int, "NVMeoF address family (0 - IPv4, 1 - IPv6)", True, 0),
139+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
131140
},
132141
)
133142
@empty_response
@@ -138,9 +147,10 @@ def create(
138147
host_name: str,
139148
traddr: str,
140149
trsvcid: int = 4420,
141-
adrfam: int = 0, # IPv4
150+
adrfam: int = 0, # IPv4,
151+
gw_group: Optional[str] = None
142152
):
143-
return NVMeoFClient(traddr=traddr).stub.create_listener(
153+
return NVMeoFClient(gw_group=gw_group, traddr=traddr).stub.create_listener(
144154
NVMeoFClient.pb2.create_listener_req(
145155
nqn=nqn,
146156
host_name=host_name,
@@ -158,6 +168,7 @@ def create(
158168
"traddr": Param(str, "NVMeoF transport address"),
159169
"trsvcid": Param(int, "NVMeoF transport service port", True, 4420),
160170
"adrfam": Param(int, "NVMeoF address family (0 - IPv4, 1 - IPv6)", True, 0),
171+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
161172
},
162173
)
163174
@empty_response
@@ -170,8 +181,9 @@ def delete(
170181
trsvcid: int = 4420,
171182
adrfam: int = 0, # IPv4
172183
force: bool = False,
184+
gw_group: Optional[str] = None
173185
):
174-
return NVMeoFClient().stub.delete_listener(
186+
return NVMeoFClient(gw_group=gw_group).stub.delete_listener(
175187
NVMeoFClient.pb2.delete_listener_req(
176188
nqn=nqn,
177189
host_name=host_name,
@@ -187,12 +199,15 @@ def delete(
187199
class NVMeoFNamespace(RESTController):
188200
@EndpointDoc(
189201
"List all NVMeoF namespaces in a subsystem",
190-
parameters={"nqn": Param(str, "NVMeoF subsystem NQN")},
202+
parameters={
203+
"nqn": Param(str, "NVMeoF subsystem NQN"),
204+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
205+
},
191206
)
192207
@map_collection(model.Namespace, pick="namespaces")
193208
@handle_nvmeof_error
194-
def list(self, nqn: str):
195-
return NVMeoFClient().stub.list_namespaces(
209+
def list(self, nqn: str, gw_group: Optional[str] = None):
210+
return NVMeoFClient(gw_group=gw_group).stub.list_namespaces(
196211
NVMeoFClient.pb2.list_namespaces_req(subsystem=nqn)
197212
)
198213

@@ -201,12 +216,13 @@ def list(self, nqn: str):
201216
parameters={
202217
"nqn": Param(str, "NVMeoF subsystem NQN"),
203218
"nsid": Param(str, "NVMeoF Namespace ID"),
219+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
204220
},
205221
)
206222
@map_model(model.Namespace, first="namespaces")
207223
@handle_nvmeof_error
208-
def get(self, nqn: str, nsid: str):
209-
return NVMeoFClient().stub.list_namespaces(
224+
def get(self, nqn: str, nsid: str, gw_group: Optional[str] = None):
225+
return NVMeoFClient(gw_group=gw_group).stub.list_namespaces(
210226
NVMeoFClient.pb2.list_namespaces_req(subsystem=nqn, nsid=int(nsid))
211227
)
212228

@@ -217,12 +233,13 @@ def get(self, nqn: str, nsid: str):
217233
parameters={
218234
"nqn": Param(str, "NVMeoF subsystem NQN"),
219235
"nsid": Param(str, "NVMeoF Namespace ID"),
236+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
220237
},
221238
)
222239
@map_model(model.NamespaceIOStats)
223240
@handle_nvmeof_error
224-
def io_stats(self, nqn: str, nsid: str):
225-
return NVMeoFClient().stub.namespace_get_io_stats(
241+
def io_stats(self, nqn: str, nsid: str, gw_group: Optional[str] = None):
242+
return NVMeoFClient(gw_group=gw_group).stub.namespace_get_io_stats(
226243
NVMeoFClient.pb2.namespace_get_io_stats_req(
227244
subsystem_nqn=nqn, nsid=int(nsid))
228245
)
@@ -237,6 +254,7 @@ def io_stats(self, nqn: str, nsid: str):
237254
"size": Param(int, "RBD image size"),
238255
"block_size": Param(int, "NVMeoF namespace block size"),
239256
"load_balancing_group": Param(int, "Load balancing group"),
257+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
240258
},
241259
)
242260
@map_model(model.NamespaceCreation)
@@ -250,8 +268,9 @@ def create(
250268
size: Optional[int] = 1024,
251269
block_size: int = 512,
252270
load_balancing_group: Optional[int] = None,
271+
gw_group: Optional[str] = None,
253272
):
254-
return NVMeoFClient().stub.namespace_add(
273+
return NVMeoFClient(gw_group=gw_group).stub.namespace_add(
255274
NVMeoFClient.pb2.namespace_add_req(
256275
subsystem_nqn=nqn,
257276
rbd_image_name=rbd_image_name,
@@ -274,6 +293,7 @@ def create(
274293
"rw_mbytes_per_second": Param(int, "Read/Write MB/s"),
275294
"r_mbytes_per_second": Param(int, "Read MB/s"),
276295
"w_mbytes_per_second": Param(int, "Write MB/s"),
296+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
277297
},
278298
)
279299
@empty_response
@@ -288,12 +308,13 @@ def update(
288308
rw_mbytes_per_second: Optional[int] = None,
289309
r_mbytes_per_second: Optional[int] = None,
290310
w_mbytes_per_second: Optional[int] = None,
311+
gw_group: Optional[str] = None
291312
):
292313
if rbd_image_size:
293314
mib = 1024 * 1024
294315
new_size_mib = int((rbd_image_size + mib - 1) / mib)
295316

296-
response = NVMeoFClient().stub.namespace_resize(
317+
response = NVMeoFClient(gw_group=gw_group).stub.namespace_resize(
297318
NVMeoFClient.pb2.namespace_resize_req(
298319
subsystem_nqn=nqn, nsid=int(nsid), new_size=new_size_mib
299320
)
@@ -336,12 +357,13 @@ def update(
336357
parameters={
337358
"nqn": Param(str, "NVMeoF subsystem NQN"),
338359
"nsid": Param(str, "NVMeoF Namespace ID"),
360+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
339361
},
340362
)
341363
@empty_response
342364
@handle_nvmeof_error
343-
def delete(self, nqn: str, nsid: str):
344-
return NVMeoFClient().stub.namespace_delete(
365+
def delete(self, nqn: str, nsid: str, gw_group: Optional[str] = None):
366+
return NVMeoFClient(gw_group=gw_group).stub.namespace_delete(
345367
NVMeoFClient.pb2.namespace_delete_req(subsystem_nqn=nqn, nsid=int(nsid))
346368
)
347369

@@ -351,7 +373,10 @@ def delete(self, nqn: str, nsid: str):
351373
class NVMeoFHost(RESTController):
352374
@EndpointDoc(
353375
"List all allowed hosts for an NVMeoF subsystem",
354-
parameters={"nqn": Param(str, "NVMeoF subsystem NQN")},
376+
parameters={
377+
"nqn": Param(str, "NVMeoF subsystem NQN"),
378+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
379+
},
355380
)
356381
@map_collection(
357382
model.Host,
@@ -362,8 +387,8 @@ class NVMeoFHost(RESTController):
362387
else o,
363388
)
364389
@handle_nvmeof_error
365-
def list(self, nqn: str):
366-
return NVMeoFClient().stub.list_hosts(
390+
def list(self, nqn: str, gw_group: Optional[str] = None):
391+
return NVMeoFClient(gw_group=gw_group).stub.list_hosts(
367392
NVMeoFClient.pb2.list_hosts_req(subsystem=nqn)
368393
)
369394

@@ -372,12 +397,13 @@ def list(self, nqn: str):
372397
parameters={
373398
"nqn": Param(str, "NVMeoF subsystem NQN"),
374399
"host_nqn": Param(str, 'NVMeoF host NQN. Use "*" to allow any host.'),
400+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
375401
},
376402
)
377403
@empty_response
378404
@handle_nvmeof_error
379-
def create(self, nqn: str, host_nqn: str):
380-
return NVMeoFClient().stub.add_host(
405+
def create(self, nqn: str, host_nqn: str, gw_group: Optional[str] = None):
406+
return NVMeoFClient(gw_group=gw_group).stub.add_host(
381407
NVMeoFClient.pb2.add_host_req(subsystem_nqn=nqn, host_nqn=host_nqn)
382408
)
383409

@@ -386,12 +412,13 @@ def create(self, nqn: str, host_nqn: str):
386412
parameters={
387413
"nqn": Param(str, "NVMeoF subsystem NQN"),
388414
"host_nqn": Param(str, 'NVMeoF host NQN. Use "*" to disallow any host.'),
415+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
389416
},
390417
)
391418
@empty_response
392419
@handle_nvmeof_error
393-
def delete(self, nqn: str, host_nqn: str):
394-
return NVMeoFClient().stub.remove_host(
420+
def delete(self, nqn: str, host_nqn: str, gw_group: Optional[str] = None):
421+
return NVMeoFClient(gw_group=gw_group).stub.remove_host(
395422
NVMeoFClient.pb2.remove_host_req(subsystem_nqn=nqn, host_nqn=host_nqn)
396423
)
397424

@@ -400,12 +427,15 @@ def delete(self, nqn: str, host_nqn: str):
400427
class NVMeoFConnection(RESTController):
401428
@EndpointDoc(
402429
"List all NVMeoF Subsystem Connections",
403-
parameters={"nqn": Param(str, "NVMeoF subsystem NQN")},
430+
parameters={
431+
"nqn": Param(str, "NVMeoF subsystem NQN"),
432+
"gw_group": Param(str, "NVMeoF gateway group", True, None),
433+
},
404434
)
405435
@map_collection(model.Connection, pick="connections")
406436
@handle_nvmeof_error
407-
def list(self, nqn: str):
408-
return NVMeoFClient().stub.list_connections(
437+
def list(self, nqn: str, gw_group: Optional[str] = None):
438+
return NVMeoFClient(gw_group=gw_group).stub.list_connections(
409439
NVMeoFClient.pb2.list_connections_req(subsystem=nqn)
410440
)
411441

0 commit comments

Comments
 (0)