|
7 | 7 | from orchestrator import OrchestratorError |
8 | 8 |
|
9 | 9 | from .. import mgr |
| 10 | +from ..exceptions import DashboardException |
10 | 11 | from ..model import nvmeof as model |
11 | 12 | from ..security import Scope |
12 | 13 | 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, |
430 | 431 | "nvmeof namespace add", model.NamespaceCreation, alias="nvmeof ns add" |
431 | 432 | ) |
432 | 433 | @EndpointDoc( |
433 | | - "Create a new NVMeoF namespace", |
| 434 | + "Create a new NVMeoF namespace.", |
434 | 435 | parameters={ |
435 | 436 | "nqn": Param(str, "NVMeoF subsystem NQN"), |
436 | 437 | "rbd_pool": Param(str, "RBD pool name"), |
437 | 438 | "rbd_image_name": Param(str, "RBD image name"), |
438 | 439 | "create_image": Param(bool, "Create RBD image"), |
439 | | - "size": Param(int, "RBD image size"), |
| 440 | + "size": Param(int, "Deprecated. Use `rbd_image_size` instead"), |
440 | 441 | "rbd_image_size": Param(int, "RBD image size"), |
441 | 442 | "trash_image": Param(bool, "Trash the RBD image when namespace is removed"), |
442 | 443 | "block_size": Param(int, "NVMeoF namespace block size"), |
@@ -476,6 +477,14 @@ def create( |
476 | 477 | gw_group: Optional[str] = None, |
477 | 478 | traddr: Optional[str] = None, |
478 | 479 | ): |
| 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 | + |
479 | 488 | size_b = rbd_image_size_b = None |
480 | 489 | if size: |
481 | 490 | size_b = convert_to_bytes(size, default_unit='MB') |
|
0 commit comments