]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch: add mon hook
authorSage Weil <sage@redhat.com>
Wed, 12 Feb 2020 21:05:29 +0000 (15:05 -0600)
committerSage Weil <sage@redhat.com>
Thu, 13 Feb 2020 15:43:38 +0000 (09:43 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index 268c475f9e3e6f47d5bb12cc82f57d75545c0e3f..1621d091a4500ea2ab6cb8d84a2a1f6c470a3bca 100644 (file)
@@ -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"""
index ff97221c483a21ddd7360e40fb798cea6d577e25..0f6b9ffe50bf2be3a83fc375d5e32adc1c80d3f1 100644 (file)
@@ -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 "