Skip to content

Commit 3ff7d73

Browse files
Tomer HaskalovitchHezko
authored andcommitted
mgr/dashboard: raise exception if both size and rbd_image_size are being passed in ns add
Signed-off-by: Tomer Haskalovitch <[email protected]>
1 parent ee37978 commit 3ff7d73

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from orchestrator import OrchestratorError
88

99
from .. import mgr
10+
from ..exceptions import DashboardException
1011
from ..model import nvmeof as model
1112
from ..security import Scope
1213
from ..services.nvmeof_cli import NvmeofCLICommand, convert_to_bytes
@@ -430,13 +431,13 @@ def io_stats(self, nqn: str, nsid: str, gw_group: Optional[str] = None,
430431
"nvmeof namespace add", model.NamespaceCreation, alias="nvmeof ns add"
431432
)
432433
@EndpointDoc(
433-
"Create a new NVMeoF namespace",
434+
"Create a new NVMeoF namespace.",
434435
parameters={
435436
"nqn": Param(str, "NVMeoF subsystem NQN"),
436437
"rbd_pool": Param(str, "RBD pool name"),
437438
"rbd_image_name": Param(str, "RBD image name"),
438439
"create_image": Param(bool, "Create RBD image"),
439-
"size": Param(int, "RBD image size"),
440+
"size": Param(int, "Deprecated. Use `rbd_image_size` instead"),
440441
"rbd_image_size": Param(int, "RBD image size"),
441442
"trash_image": Param(bool, "Trash the RBD image when namespace is removed"),
442443
"block_size": Param(int, "NVMeoF namespace block size"),
@@ -476,6 +477,14 @@ def create(
476477
gw_group: Optional[str] = None,
477478
traddr: Optional[str] = None,
478479
):
480+
if size and rbd_image_size:
481+
raise DashboardException(
482+
msg="Can use size or rbd_image_size but not both",
483+
code="can_use_size_or_rbd_image_size_but_not_both",
484+
http_status_code=400,
485+
component="nvmeof",
486+
)
487+
479488
size_b = rbd_image_size_b = None
480489
if size:
481490
size_b = convert_to_bytes(size, default_unit='MB')

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9385,7 +9385,7 @@ paths:
93859385
description: Read only namespace
93869386
type: string
93879387
size:
9388-
description: RBD image size
9388+
description: Deprecated. Use `rbd_image_size` instead
93899389
type: integer
93909390
traddr:
93919391
description: Target gateway address
@@ -9419,7 +9419,7 @@ paths:
94199419
trace.
94209420
security:
94219421
- jwt: []
9422-
summary: Create a new NVMeoF namespace
9422+
summary: Create a new NVMeoF namespace.
94239423
tags:
94249424
- NVMe-oF Subsystem Namespace
94259425
/api/nvmeof/subsystem/{nqn}/namespace/{nsid}:

0 commit comments

Comments
 (0)