raise OrchestratorValidationError("num/count must be > 1")
@classmethod
- def from_strings(cls, arg):
+ def from_string(cls, arg):
# type: (Optional[str]) -> PlacementSpec
"""
A single integer is parsed as a count:
- >>> PlacementSpec.from_strings('3'.split())
+ >>> PlacementSpec.from_string('3')
PlacementSpec(count=3)
A list of names is parsed as host specifications:
- >>> PlacementSpec.from_strings('host1 host2'.split())
+ >>> PlacementSpec.from_string('host1 host2')
PlacementSpec(label=[HostSpec(hostname='host1', network='', name=''), HostSpec(hostname='host2', network='', name='')])
You can also prefix the hosts with a count as follows:
- >>> PlacementSpec.from_strings('2 host1 host2'.split())
+ >>> PlacementSpec.from_string('2 host1 host2')
PlacementSpec(label=[HostSpec(hostname='host1', network='', name=''), HostSpec(hostname='host2', network='', name='')], count=2)
You can spefify labels using `label:<label>`
- >>> PlacementSpec.from_strings('label:mon'.split())
+ >>> PlacementSpec.from_string('label:mon')
PlacementSpec(label='label:mon')
Labels als support a count:
- >>> PlacementSpec.from_strings('3 label:mon'.split())
+ >>> PlacementSpec.from_string('3 label:mon')
PlacementSpec(label='label:mon', count=3)
- >>> PlacementSpec.from_strings(None)
+ >>> PlacementSpec.from_string(None)
PlacementSpec()
"""
if arg is None:
strings = arg.split(',')
else:
strings = [arg]
- elif isinstance(arg, list):
- strings = arg
else:
raise OrchestratorValidationError('invalid placement %s' % arg)
'name=placement,type=CephString,req=false',
'Start monitor daemon(s)')
def _daemon_add_mon(self, placement=None):
- placement = PlacementSpec.from_strings(placement)
+ placement = PlacementSpec.from_string(placement)
placement.validate()
spec = ServiceSpec('mon', placement=placement)
def _daemon_add_mgr(self, placement=None):
spec = ServiceSpec(
'mgr',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_mgr(spec)
self._orchestrator_wait([completion])
def _rbd_mirror_add(self, placement=None):
spec = ServiceSpec(
'rbd-mirror',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_rbd_mirror(spec)
self._orchestrator_wait([completion])
def _mds_add(self, fs_name, placement=None):
spec = ServiceSpec(
'mds', fs_name,
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_mds(spec)
self._orchestrator_wait([completion])
rgw_spec = RGWSpec(
rgw_realm=realm_name,
rgw_zone=zone_name,
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_rgw(rgw_spec)
svc_arg,
pool=pool,
namespace=namespace,
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
spec.validate_add()
completion = self.add_nfs(spec)
def _daemon_add_prometheus(self, placement=None):
spec = ServiceSpec(
'prometheus',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_prometheus(spec)
self._orchestrator_wait([completion])
def _daemon_add_node_exporter(self, placement=None):
spec = ServiceSpec(
'node-exporter',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_node_exporter(spec)
self._orchestrator_wait([completion])
def _daemon_add_crash(self, placement=None):
spec = ServiceSpec(
'crash',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_crash(spec)
self._orchestrator_wait([completion])
# type: (Optional[str]) -> HandleCommandResult
spec = ServiceSpec(
'grafana',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_grafana(spec)
self._orchestrator_wait([completion])
# type: (Optional[str]) -> HandleCommandResult
spec = ServiceSpec(
'alertmanager',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.add_alertmanager(spec)
self._orchestrator_wait([completion])
'name=placement,type=CephString,req=false',
'Update the size or placement of managers')
def _apply_mgr(self, placement=None):
- placement = PlacementSpec.from_strings(placement)
+ placement = PlacementSpec.from_string(placement)
placement.validate()
spec = ServiceSpec('mgr', placement=placement)
'name=placement,type=CephString,req=false',
'Update the number of monitor instances')
def _apply_mon(self, placement=None):
- placement = PlacementSpec.from_strings(placement)
+ placement = PlacementSpec.from_string(placement)
placement.validate()
spec = ServiceSpec('mon', placement=placement)
'name=placement,type=CephString,req=false',
'Update the number of MDS instances for the given fs_name')
def _apply_mds(self, fs_name, placement=None):
- placement = PlacementSpec.from_strings(placement)
+ placement = PlacementSpec.from_string(placement)
placement.validate()
spec = ServiceSpec(
'mds', fs_name,
def _apply_rbd_mirror(self, placement=None):
spec = ServiceSpec(
'rbd-mirror',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_rbd_mirror(spec)
self._orchestrator_wait([completion])
spec = RGWSpec(
rgw_realm=realm_name,
rgw_zone=zone_name,
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_rgw(spec)
self._orchestrator_wait([completion])
def _apply_nfs(self, svc_id, placement=None):
spec = NFSServiceSpec(
svc_id,
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_nfs(spec)
self._orchestrator_wait([completion])
def _apply_prometheus(self, placement=None):
spec = ServiceSpec(
'prometheus',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_prometheus(spec)
self._orchestrator_wait([completion])
def _apply_grafana(self, placement=None):
spec = ServiceSpec(
'grafana',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_grafana(spec)
self._orchestrator_wait([completion])
def _apply_alertmanager(self, placement=None):
spec = ServiceSpec(
'alertmanager',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_alertmanager(spec)
self._orchestrator_wait([completion])
def _apply_node_exporter(self, placement=None):
spec = ServiceSpec(
'node-exporter',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_node_exporter(spec)
self._orchestrator_wait([completion])
def _apply_crash(self, placement=None):
spec = ServiceSpec(
'crash',
- placement=PlacementSpec.from_strings(placement),
+ placement=PlacementSpec.from_string(placement),
)
completion = self.apply_crash(spec)
self._orchestrator_wait([completion])