'entity': 'mon.',
})
- # infer whether this is a CIDR network, addrvec, or plain IP
extra_config = '[mon.%s]\n' % name
- if '/' in network:
- extra_config += 'public network = %s\n' % network
- elif network.startswith('[v') and network.endswith(']'):
- extra_config += 'public addrv = %s\n' % network
- elif ':' not in network:
- extra_config += 'public addr = %s\n' % network
+ if network:
+ # infer whether this is a CIDR network, addrvec, or plain IP
+ if '/' in network:
+ extra_config += 'public network = %s\n' % network
+ elif network.startswith('[v') and network.endswith(']'):
+ extra_config += 'public addrv = %s\n' % network
+ elif ':' not in network:
+ extra_config += 'public addr = %s\n' % network
+ else:
+ raise OrchestratorError('Must specify a CIDR network, ceph addrvec, or plain IP: \'%s\'' % network)
else:
- raise RuntimeError('Must specify a CIDR network, ceph addrvec, or plain IP: \'%s\'' % network)
+ # try to get the public_network from the config
+ ret, network, err = self.mon_command({
+ 'prefix': 'config get',
+ 'who': 'mon',
+ 'key': 'public_network',
+ })
+ network = network.strip() # type: ignore
+ if ret:
+ raise RuntimeError('Unable to fetch cluster_network config option')
+ if not network:
+ raise OrchestratorError('Must set public_network config option or specify a CIDR network, ceph addrvec, or plain IP')
+ if '/' not in network:
+ raise OrchestratorError('public_network is set but does not look like a CIDR network: \'%s\'' % network)
+ extra_config += 'public network = %s\n' % network
return self._create_daemon('mon', name, host,
keyring=keyring,
def add_mon(self, spec):
# type: (orchestrator.ServiceSpec) -> orchestrator.Completion
- # current support requires a network to be specified
- orchestrator.servicespec_validate_hosts_have_network_spec(spec)
return self._add_daemon('mon', spec, self._create_mon)
def _create_mgr(self, mgr_id, host):
assert wait(cephadm_module, c) == [what + " rgw.myrgw.foobar from host 'test'"]
- def test_mon_update(self, cephadm_module):
+ def test_mon_add(self, cephadm_module):
with self._with_host(cephadm_module, 'test'):
ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1)
c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps))
assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"]
- with pytest.raises(OrchestratorError, match="is missing a network spec"):
+ with pytest.raises(OrchestratorError, match="Must set public_network config option or specify a CIDR network,"):
ps = PlacementSpec(hosts=['test'], count=1)
c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps))
wait(cephadm_module, c)
Orchestrator, OrchestratorClientMixin, \
OrchestratorValidationError, OrchestratorError, NoOrchestrator, \
ServiceSpec, NFSServiceSpec, RGWSpec, HostPlacementSpec, \
- servicespec_validate_add, servicespec_validate_hosts_have_network_spec, \
+ servicespec_validate_add, \
ServiceDescription, InventoryFilter, PlacementSpec, HostSpec, \
DaemonDescription, \
InventoryHost, DeviceLightLoc, \
raise OrchestratorValidationError('Cannot add Service: id required')
-def servicespec_validate_hosts_have_network_spec(self: ServiceSpec):
- # This must not be a method of ServiceSpec, otherwise you'll hunt
- # sub-interpreter affinity bugs.
- if not self.placement.hosts:
- raise OrchestratorValidationError('Service specification: no hosts provided')
-
- for host, network, _ in self.placement.hosts:
- if not network:
- m = "Host '{host}' is missing a network spec\nE.g. {host}:1.2.3.0/24".format(
- host=host)
- logger.error(
- f'validate_hosts_have_network_spec: id(OrchestratorValidationError)={id(OrchestratorValidationError)}')
- raise OrchestratorValidationError(m)
-
class NFSServiceSpec(ServiceSpec):
def __init__(self, service_id, pool=None, namespace=None, placement=None,