]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ssh: optionally specify names for mgr daemons
authorSage Weil <sage@redhat.com>
Mon, 11 Nov 2019 16:26:13 +0000 (10:26 -0600)
committerSage Weil <sage@redhat.com>
Tue, 12 Nov 2019 15:00:48 +0000 (09:00 -0600)
Use '=' as a separator.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/ssh/module.py

index 6f9f3c30008b7c9e33bafbff9d950bd2580a37a0..4bcfc3c985ea3bef21b5c58f986d0200925f8bc1 100644 (file)
@@ -551,6 +551,23 @@ Usage:
             return HandleCommandResult(-errno.EINVAL,
                     stderr="Invalid number of mgrs: require {} > 0".format(num))
 
+        def split_host(host):
+            """Split host into host and name parts"""
+            # TODO: stricter validation
+            a = host.split('=', 1)
+            if len(a) == 1:
+                return (a[0], None)
+            else:
+                assert len(a) == 2
+                return tuple(a)
+
+        if hosts:
+            try:
+                hosts = list(map(split_host, hosts))
+            except Exception as e:
+                msg = "Failed to parse host list: '{}': {}".format(hosts, e)
+                return HandleCommandResult(-errno.EINVAL, stderr=msg)
+
         completion = self.update_mgrs(num, hosts)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
index 62beeb7abe55feea7931e2897f851c52846ce536..dd22a86aa9cbc0ba49061cad6253fecc13bd1389 100644 (file)
@@ -941,7 +941,7 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             return SSHWriteCompletionReady("The requested number of managers exist.")
 
         # check that all the hosts are registered
-        self._require_hosts(hosts)
+        self._require_hosts(map(lambda h: h[0], hosts))
 
         results = []
         if num < num_mgrs:
@@ -987,13 +987,19 @@ class SSHOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
                     "Error: {} hosts provided, expected {}".format(
                         len(hosts), num_new_mgrs))
 
+            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)
+
             self.log.info("creating {} managers on hosts: '{}'".format(
-                num_new_mgrs, ",".join(hosts)))
+                num_new_mgrs, ",".join(map(lambda h: h[0], hosts))))
 
             for i in range(num_new_mgrs):
-                name = self.get_unique_name(daemons)
+                host, name = hosts[i]
+                if not name:
+                    name = self.get_unique_name(daemons)
                 result = self._worker_pool.apply_async(self._create_mgr,
-                                                       (hosts[i], name))
+                                                       (host, name))
                 results.append(result)
 
         return SSHWriteCompletion(results)