]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch_cli: allow multiple drivegroups
authorJoshua Schmid <jschmid@suse.de>
Fri, 6 Dec 2019 14:42:30 +0000 (15:42 +0100)
committerJoshua Schmid <jschmid@suse.de>
Tue, 28 Jan 2020 15:49:42 +0000 (16:49 +0100)
Signed-off-by: Joshua Schmid <jschmid@suse.de>
src/pybind/mgr/orchestrator_cli/module.py

index 9138ff71134abe4049105b264f96c8cf1955c176..458a3537b0dbd3204f5da57db5b651b5f607dad9 100644 (file)
@@ -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 <json_file>
+  ceph orchestrator osd create -i <json_file/yaml_file>
   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(