def _rbd_mirror_add(self, num=None, hosts=None): spec = orchestrator.StatelessServiceSpec( None, placement=orchestrator.PlacementSpec(hosts=hosts, count=num)) completion = self.add_rbd_mirror(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _rgw_add(self, zone_name, num, hosts, inbuf=None): usage = """ Usage: ceph orchestrator rgw add -i <json_file> ceph orchestrator rgw add <zone_name> """ if inbuf: try: rgw_spec = orchestrator.RGWSpec.from_json(json.loads(inbuf)) except ValueError as e: msg = 'Failed to read JSON input: {}'.format(str(e)) + usage return HandleCommandResult(-errno.EINVAL, stderr=msg) elif zone_name: rgw_spec = orchestrator.RGWSpec( rgw_zone=zone_name, placement=orchestrator.PlacementSpec(nodes=hosts), count=num or 1) else: return HandleCommandResult(-errno.EINVAL, stderr=usage) completion = self.add_rgw(rgw_spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
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 _rgw_update(self, zone_name, num, hosts=None): spec = orchestrator.RGWSpec( rgw_zone=zone_name, placement=orchestrator.PlacementSpec(nodes=hosts), count=num or 1) completion = self.update_rgw(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _mds_update(self, fs_name, num, hosts=None): spec = orchestrator.StatelessServiceSpec( fs_name, placement=orchestrator.PlacementSpec(nodes=hosts), count=num or 1) completion = self.update_mds(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())
def _nfs_update(self, svc_id, num=None, label=None, hosts=[]): # type: (str, Optional[int], Optional[str], List[str]) -> HandleCommandResult spec = orchestrator.NFSServiceSpec( svc_id, placement=orchestrator.PlacementSpec(label=label, hosts=hosts, count=num), ) completion = self.update_nfs(spec) self._orchestrator_wait([completion]) return HandleCommandResult(stdout=completion.result_str())
def _rgw_update(self, zone_name, realm_name, num=None, label=None, hosts=[]): spec = orchestrator.RGWSpec( rgw_realm=realm_name, rgw_zone=zone_name, placement=orchestrator.PlacementSpec(hosts=hosts, label=label, count=num)) completion = self.update_rgw(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 _nfs_add(self, svc_arg, pool, namespace=None, num=None, label=None, hosts=[]): spec = orchestrator.NFSServiceSpec( svc_arg, pool=pool, namespace=namespace, placement=orchestrator.PlacementSpec(label=label, hosts=hosts, count=num), ) spec.validate_add() completion = self.add_nfs(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 _update_mons(self, num=None, hosts=[], label=None): placement = orchestrator.PlacementSpec(label=label, count=num, hosts=hosts) if not hosts and not label: # Improve Error message. Point to parse_host_spec examples raise orchestrator.OrchestratorValidationError( "Mons need a host spec. (host, network, name(opt))") # TODO: Scaling without a HostSpec doesn't work right now. # we need network autodetection for that. # placement = orchestrator.PlacementSpec(count=num) placement.validate() spec = orchestrator.StatefulServiceSpec(placement=placement) completion = self.update_mons(spec) self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str())