From: Joshua Schmid Date: Fri, 6 Dec 2019 14:42:30 +0000 (+0100) Subject: mgr/orch_cli: allow multiple drivegroups X-Git-Tag: v15.1.1~612^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12e201b23665f8d7c106af00177487558ef201bf;p=ceph.git mgr/orch_cli: allow multiple drivegroups Signed-off-by: Joshua Schmid --- diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 9138ff71134a..458a3537b0db 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(