From 3ff7d737bb1934dbfe26d86a819727d9456a6da6 Mon Sep 17 00:00:00 2001 From: Tomer Haskalovitch Date: Thu, 18 Sep 2025 10:58:44 +0300 Subject: [PATCH] mgr/dashboard: raise exception if both size and rbd_image_size are being passed in ns add Signed-off-by: Tomer Haskalovitch --- src/pybind/mgr/dashboard/controllers/nvmeof.py | 13 +++++++++++-- src/pybind/mgr/dashboard/openapi.yaml | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index a26cbe3056d87..643b2914ae126 100644 --- a/src/pybind/mgr/dashboard/controllers/nvmeof.py +++ b/src/pybind/mgr/dashboard/controllers/nvmeof.py @@ -7,6 +7,7 @@ import cherrypy from orchestrator import OrchestratorError from .. import mgr +from ..exceptions import DashboardException from ..model import nvmeof as model from ..security import Scope from ..services.nvmeof_cli import NvmeofCLICommand, convert_to_bytes @@ -430,13 +431,13 @@ else: "nvmeof namespace add", model.NamespaceCreation, alias="nvmeof ns add" ) @EndpointDoc( - "Create a new NVMeoF namespace", + "Create a new NVMeoF namespace.", parameters={ "nqn": Param(str, "NVMeoF subsystem NQN"), "rbd_pool": Param(str, "RBD pool name"), "rbd_image_name": Param(str, "RBD image name"), "create_image": Param(bool, "Create RBD image"), - "size": Param(int, "RBD image size"), + "size": Param(int, "Deprecated. Use `rbd_image_size` instead"), "rbd_image_size": Param(int, "RBD image size"), "trash_image": Param(bool, "Trash the RBD image when namespace is removed"), "block_size": Param(int, "NVMeoF namespace block size"), @@ -476,6 +477,14 @@ else: gw_group: Optional[str] = None, traddr: Optional[str] = None, ): + if size and rbd_image_size: + raise DashboardException( + msg="Can use size or rbd_image_size but not both", + code="can_use_size_or_rbd_image_size_but_not_both", + http_status_code=400, + component="nvmeof", + ) + size_b = rbd_image_size_b = None if size: size_b = convert_to_bytes(size, default_unit='MB') diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index d6a8011179801..56bdeb6dec9bf 100755 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -9385,7 +9385,7 @@ paths: description: Read only namespace type: string size: - description: RBD image size + description: Deprecated. Use `rbd_image_size` instead type: integer traddr: description: Target gateway address @@ -9419,7 +9419,7 @@ paths: trace. security: - jwt: [] - summary: Create a new NVMeoF namespace + summary: Create a new NVMeoF namespace. tags: - NVMe-oF Subsystem Namespace /api/nvmeof/subsystem/{nqn}/namespace/{nsid}: -- 2.39.5