]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: `orch daemon add` accepts a yaml
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 17 Mar 2020 11:11:36 +0000 (12:11 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 18 Mar 2020 10:03:20 +0000 (11:03 +0100)
Fixes: https://tracker.ceph.com/issues/44622
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/orchestrator/module.py

index a405cf42cdbd8e9375b34f97ee58f160ef043d69..d7bb43bdd80f031d45bdf0e54d13924cfcb27919 100644 (file)
@@ -536,14 +536,22 @@ Usage:
 
     @_cli_write_command(
         'orch daemon add',
-        'name=daemon_type,type=CephChoices,strings=mon|mgr|rbd-mirror|crash|alertmanager|grafana|node-exporter|prometheus '
+        'name=daemon_type,type=CephChoices,strings=mon|mgr|rbd-mirror|crash|alertmanager|grafana|node-exporter|prometheus,req=false '
         'name=placement,type=CephString,req=false',
         'Add daemon(s)')
-    def _daemon_add_misc(self, daemon_type, placement=None):
-        placement = PlacementSpec.from_string(placement)
-        placement.validate()
+    def _daemon_add_misc(self, daemon_type=None, placement=None, inbuf=None):
+        usage = f"""Usage:
+    ceph orch daemon add -i <json_file>
+    ceph orch daemon add {daemon_type or '<daemon_type>'} <placement>"""
+        if inbuf:
+            if daemon_type or placement:
+                raise OrchestratorValidationError(usage)
+            spec = ServiceSpec.from_json(yaml.safe_load(inbuf))
+        else:
+            placement = PlacementSpec.from_string(placement)
+            placement.validate()
 
-        spec = ServiceSpec(daemon_type, placement=placement)
+            spec = ServiceSpec(daemon_type, placement=placement)
 
         if daemon_type == 'mon':
             completion = self.add_mon(spec)
@@ -561,6 +569,8 @@ Usage:
             completion = self.add_node_exporter(spec)
         elif daemon_type == 'prometheus':
             completion = self.add_prometheus(spec)
+        else:
+            raise OrchestratorValidationError(f'unknown daemon type `{daemon_type}`')
 
         self._orchestrator_wait([completion])
         raise_if_exception(completion)