From 62b0e42360931a90a89af5670c6efd252abb94da Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 12 Feb 2020 15:05:29 -0600 Subject: [PATCH] mgr/orch: add mon hook Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator.py | 5 +++++ src/pybind/mgr/orchestrator_cli/module.py | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 268c475f9e3..1621d091a45 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -960,6 +960,11 @@ class Orchestrator(object): """ raise NotImplementedError() + def add_mon(self, spec): + # type: (ServiceSpec) -> Completion + """Create a new mon daemon""" + raise NotImplementedError() + def add_mgr(self, spec): # type: (ServiceSpec) -> Completion """Create a new mgr daemon""" diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index ff97221c483..0f6b9ffe50b 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -387,6 +387,26 @@ Usage: orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( + 'orch daemon add mon', + "name=num,type=CephInt,req=false " + "name=hosts,type=CephString,n=N,req=false " + "name=label,type=CephString,req=false", + 'Start monitor daemon(s)') + def _daemon_add_mon(self, num=None, hosts=[], label=None): + if not num and not hosts and not label: + # Improve Error message. Point to parse_host_spec examples + raise orchestrator.OrchestratorValidationError("Mons need a placement spec. (num, host, network, name(opt))") + placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) + placement.validate() + + spec = orchestrator.ServiceSpec(placement=placement) + + completion = self.add_mon(spec) + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( 'orch daemon add mgr', "name=num,type=CephInt,req=false " -- 2.39.5