]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ssh: optionally specify names for mon daemons
authorSage Weil <sage@redhat.com>
Mon, 11 Nov 2019 16:52:34 +0000 (10:52 -0600)
committerSage Weil <sage@redhat.com>
Tue, 12 Nov 2019 15:00:52 +0000 (09:00 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/ssh/module.py

index dc9e57f2fe9ed7a686b0b80279d99932469626fa..fb634eac7c70bb93ba2f3400ca3d8628378b3309 100644 (file)
@@ -474,7 +474,7 @@ class Orchestrator(object):
         Update the number of cluster monitors.
 
         :param num: requested number of monitors.
-        :param hosts: list of hosts + network (optional)
+        :param hosts: list of hosts + network + name (optional)
         """
         raise NotImplementedError()
 
index 4bcfc3c985ea3bef21b5c58f986d0200925f8bc1..9b402322ed468fdca1bb0f19a2f867529a46cc38 100644 (file)
@@ -587,11 +587,12 @@ Usage:
         def split_host(host):
             """Split host into host and network parts"""
             # TODO: stricter validation
+            (host, name) = host.split('=', 1)
             parts = host.split(":", 1)
             if len(parts) == 1:
-                return (parts[0], None)
+                return (parts[0], None, name)
             elif len(parts) == 2:
-                return (parts[0], parts[1])
+                return (parts[0], parts[1], name)
             else:
                 raise RuntimeError("Invalid host specification: "
                         "'{}'".format(host))
index dd22a86aa9cbc0ba49061cad6253fecc13bd1389..d648679db7693a7c067fb5fc5f85e5810c1f7c50 100644 (file)
@@ -850,7 +850,7 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             return add_func(spec)
         return SSHWriteCompletion(results)
 
-    def _create_mon(self, host, network):
+    def _create_mon(self, host, network, name):
         """
         Create a new monitor on the given host.
         """
@@ -872,7 +872,7 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         else:
             raise RuntimeError('Must specify a CIDR network, ceph addrvec, or plain IP: \'%s\'' % network)
 
-        return self._create_daemon('mon', host, host, keyring,
+        return self._create_daemon('mon', name or host, host, keyring,
                                    extra_args=extra_args)
 
     def update_mons(self, num, hosts):
@@ -891,10 +891,15 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         self._require_hosts(map(lambda h: h[0], hosts))
 
         # current support requires a network to be specified
-        for host, network in hosts:
+        for host, network, name in hosts:
             if not network:
                 raise RuntimeError("Host '{}' missing network part".format(host))
 
+        daemons = self._get_services('mon')
+        for _, _, name in hosts:
+            if name and len([d for d in daemons if d.service_instance == name]):
+                raise RuntimeError('name %s alrady exists', name)
+
         # explicit placement: enough hosts provided?
         num_new_mons = num - num_mons
         if len(hosts) < num_new_mons:
@@ -907,9 +912,9 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         # TODO: we may want to chain the creation of the monitors so they join
         # the quorum one at a time.
         results = []
-        for host, network in hosts:
-            result = self._worker_pool.apply_async(self._create_mon, (host,
-                network))
+        for host, network, name in hosts:
+            result = self._worker_pool.apply_async(self._create_mon,
+                                                   (host, network, name))
             results.append(result)
 
         return SSHWriteCompletion(results)