# 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))
+ orchestrator.servicespec_validate_hosts_have_network_spec(spec)
- 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)
+ daemons = self.daemon_cache.get_daemons_by_type('mon')
+ 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)
+ @async_completion
def apply_mon(self, spec):
# type: (orchestrator.ServiceSpec) -> orchestrator.Completion
"""
[self._require_hosts(host.hostname) for host in spec.placement.hosts]
# 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))
+ orchestrator.servicespec_validate_hosts_have_network_spec(spec)
- def update_mons_with_daemons(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 alrady exists', name)
-
- # explicit placement: enough hosts provided?
- num_new_mons = spec.count - num_mons
- if len(spec.placement.hosts) < num_new_mons:
- raise RuntimeError("Error: {} hosts provided, expected {}".format(
- len(spec.placement.hosts), num_new_mons))
- self.log.info("creating {} monitors on hosts: '{}'".format(
- num_new_mons, ",".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(update_mons_with_daemons)
+ daemons = self.daemon_cache.get_daemons_by_type('mon')
+ for _, _, name in spec.placement.hosts:
+ if name and len([d for d in daemons if d.daemon_id == name]):
+ raise RuntimeError('name %s alrady exists', name)
+
+ # explicit placement: enough hosts provided?
+ num_new_mons = spec.count - num_mons
+ if len(spec.placement.hosts) < num_new_mons:
+ raise RuntimeError("Error: {} hosts provided, expected {}".format(
+ len(spec.placement.hosts), num_new_mons))
+ self.log.info("creating {} monitors on hosts: '{}'".format(
+ num_new_mons, ",".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)
@async_map_completion
def _create_mgr(self, mgr_id, host):