From: Sebastian Wagner Date: Tue, 17 Mar 2020 11:11:36 +0000 (+0100) Subject: mgr/orchestrator: `orch daemon add` accepts a yaml X-Git-Tag: v15.2.0~22^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9c12b1b8d343999c13f12cbd5bcc1adf317dee65;p=ceph.git mgr/orchestrator: `orch daemon add` accepts a yaml Fixes: https://tracker.ceph.com/issues/44622 Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index a405cf42cdbd8..d7bb43bdd80f0 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -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 + ceph orch daemon add {daemon_type or ''} """ + 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)