From 12e201b23665f8d7c106af00177487558ef201bf Mon Sep 17 00:00:00 2001 From: Joshua Schmid Date: Fri, 6 Dec 2019 15:42:30 +0100 Subject: [PATCH] mgr/orch_cli: allow multiple drivegroups Signed-off-by: Joshua Schmid --- src/pybind/mgr/orchestrator_cli/module.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 9138ff71134ab..458a3537b0dbd 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -1,6 +1,7 @@ import datetime import errno import json +import yaml from functools import wraps from ceph.deployment.inventory import Device @@ -15,7 +16,7 @@ except ImportError: from ceph.deployment.drive_group import DriveGroupSpec, DriveGroupValidationError, \ - DeviceSelection + DeviceSelection, DriveGroupSpecs from mgr_module import MgrModule, CLICommand, HandleCommandResult import orchestrator @@ -342,13 +343,15 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule): usage = """ Usage: - ceph orchestrator osd create -i + ceph orchestrator osd create -i ceph orchestrator osd create host:device1,device2,... """ + # TODO: try if inbuf file is yaml of json if inbuf: try: - drive_group = DriveGroupSpec.from_json(json.loads(inbuf)) + dgs = DriveGroupSpecs(json.loads(inbuf)) + drive_groups = dgs.drive_groups except ValueError as e: msg = 'Failed to read JSON input: {}'.format(str(e)) + usage return HandleCommandResult(-errno.EINVAL, stderr=msg) @@ -362,14 +365,13 @@ Usage: return HandleCommandResult(-errno.EINVAL, stderr=msg) devs = DeviceSelection(paths=block_devices) - drive_group = DriveGroupSpec(node_name, data_devices=devs) + drive_groups = [DriveGroupSpec(node_name, data_devices=devs)] else: return HandleCommandResult(-errno.EINVAL, stderr=usage) - completion = self.create_osds(drive_group) + completion = self.create_osds(drive_groups) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) - self.log.warning(str(completion.result)) return HandleCommandResult(stdout=completion.result_str()) @orchestrator._cli_write_command( -- 2.39.5