def _apply_prometheus(self, num=None, label=None, hosts=[]): # type: (Optional[int], Optional[str], List[str]) -> HandleCommandResult spec = orchestrator.ServiceSpec(placement=orchestrator.PlacementSpec( label=label, hosts=hosts, count=num), ) completion = self.apply_prometheus(spec) self._orchestrator_wait([completion]) return HandleCommandResult(stdout=completion.result_str())
def _apply_rbd_mirror(self, num, label=None, hosts=[]): spec = orchestrator.ServiceSpec(placement=orchestrator.PlacementSpec( hosts=hosts, count=num, label=label)) completion = self.apply_rbd_mirror(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _daemon_add_mgr(self, num=None, hosts=None): spec = orchestrator.ServiceSpec( placement=orchestrator.PlacementSpec(hosts=hosts, count=num)) completion = self.add_mgr(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _update_mgrs(self, num=None, hosts=[], label=None): placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) placement.validate() spec = orchestrator.ServiceSpec(placement=placement) completion = self.update_mgrs(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _update_mons(self, num=None, hosts=[], label=None): if not num and not hosts and not label: # Improve Error message. Point to parse_host_spec examples raise orchestrator.OrchestratorValidationError("Mons need a placement spec. (num, host, network, name(opt))") placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) placement.validate() spec = orchestrator.ServiceSpec(placement=placement) completion = self.update_mons(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def create_mds(mgr, fs_name, placement): spec = orchestrator.ServiceSpec(fs_name, orchestrator.PlacementSpec.from_strings(placement.split())) try: completion = mgr.apply_mds(spec) mgr._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) except (ImportError, orchestrator.OrchestratorError): return 0, "", "Volume created successfully (no MDS daemons created)" except Exception as e: # Don't let detailed orchestrator exceptions (python backtraces) # bubble out to the user log.exception("Failed to create MDS daemons") return -errno.EINVAL, "", str(e) return 0, "", ""