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))
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.
"""
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):
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:
# 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)