From: Tomer Haskalovitch Date: Thu, 18 Sep 2025 07:58:44 +0000 (+0300) Subject: mgr/dashboard: raise exception if both size and rbd_image_size are being passed in... X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F65676%2Fhead;p=ceph.git mgr/dashboard: raise exception if both size and rbd_image_size are being passed in ns add Signed-off-by: Tomer Haskalovitch --- diff --git a/src/pybind/mgr/dashboard/controllers/nvmeof.py b/src/pybind/mgr/dashboard/controllers/nvmeof.py index a26cbe3056d..643b2914ae1 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 d6a80111798..56bdeb6dec9 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}: