From dc5ba5c5b4daac6e9f359147163e7005aa41f0c3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 12 Feb 2020 15:46:35 -0600 Subject: [PATCH] mgr/cephadm: add mon Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index acb0f41f8020b..648d01adcf45a 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1869,6 +1869,31 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): keyring=keyring, extra_config=extra_config) + def add_mon(self, spec): + # type: (orchestrator.ServiceSpec) -> orchestrator.Completion + + # current support requires a network to be specified + for host, network, _ in spec.placement.hosts: + if not network: + raise RuntimeError("Host '{}' is missing a network spec".format(host)) + + def add_mons(daemons): + for _, _, name in spec.placement.hosts: + if name and len([d for d in daemons if d.daemon_id == name]): + raise RuntimeError('name %s already exists', name) + + # explicit placement: enough hosts provided? + if len(spec.placement.hosts) < spec.count: + raise RuntimeError("Error: {} hosts provided, expected {}".format( + len(spec.placement.hosts), spec.count)) + self.log.info("creating {} monitors on hosts: '{}'".format( + spec.count, ",".join(map(lambda h: ":".join(h), spec.placement.hosts)))) + # TODO: we may want to chain the creation of the monitors so they join + # the quorum one at a time. + return self._create_mon(spec.placement.hosts) + + return self._get_daemons('mon').then(add_mons) + def update_mons(self, spec): # type: (orchestrator.ServiceSpec) -> orchestrator.Completion """ -- 2.39.5