From: Sage Weil Date: Fri, 13 Mar 2020 18:47:54 +0000 (-0500) Subject: mgr/orch: combine 'orch daemon add ...' into one command X-Git-Tag: v15.2.0~38^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=00608779f296c3389a14a53d45a419b4778ba3d5;p=ceph.git mgr/orch: combine 'orch daemon add ...' into one command Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 3339fb5ec1e..50e7425aa68 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -504,30 +504,33 @@ Usage: return HandleCommandResult(stdout=table.get_string()) @_cli_write_command( - 'orch daemon add mon', + 'orch daemon add', + 'name=daemon_type,type=CephChoices,strings=mon|mgr|rbd-mirror|crash|alertmanager|grafana|node-exporter|prometheus ' 'name=placement,type=CephString,req=false', - 'Start monitor daemon(s)') - def _daemon_add_mon(self, placement=None): + 'Add daemon(s)') + def _daemon_add_misc(self, daemon_type, placement=None): placement = PlacementSpec.from_string(placement) placement.validate() - spec = ServiceSpec('mon', placement=placement) + spec = ServiceSpec(daemon_type, placement=placement) - completion = self.add_mon(spec) - self._orchestrator_wait([completion]) - raise_if_exception(completion) - return HandleCommandResult(stdout=completion.result_str()) + if daemon_type == 'mon': + completion = self.add_mon(spec) + elif daemon_type == 'mgr': + completion = self.add_mgr(spec) + elif daemon_type == 'rbd-mirror': + completion = self.add_rbd_mirror(spec) + elif daemon_type == 'crash': + completion = self.add_crash(spec) + elif daemon_type == 'alertmanager': + completion = self.add_alertmanager(spec) + elif daemon_type == 'grafana': + completion = self.add_grafana(spec) + elif daemon_type == 'node-exporter': + completion = self.add_node_exporter(spec) + elif daemon_type == 'prometheus': + completion = self.add_prometheus(spec) - @_cli_write_command( - 'orch daemon add mgr', - 'name=placement,type=CephString,req=false', - 'Start rbd-mirror daemon(s)') - def _daemon_add_mgr(self, placement=None): - spec = ServiceSpec( - 'mgr', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_mgr(spec) self._orchestrator_wait([completion]) raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) @@ -541,20 +544,6 @@ Usage: raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) - @_cli_write_command( - 'orch daemon add rbd-mirror', - 'name=placement,type=CephString,req=false', - 'Start rbd-mirror daemon(s)') - def _rbd_mirror_add(self, placement=None): - spec = ServiceSpec( - 'rbd-mirror', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_rbd_mirror(spec) - self._orchestrator_wait([completion]) - raise_if_exception(completion) - return HandleCommandResult(stdout=completion.result_str()) - @_cli_write_command( 'orch daemon add mds', 'name=fs_name,type=CephString ' @@ -619,73 +608,6 @@ Usage: raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) - @_cli_write_command( - 'orch daemon add prometheus', - 'name=placement,type=CephString,req=false', - 'Add prometheus daemon(s)') - def _daemon_add_prometheus(self, placement=None): - spec = ServiceSpec( - 'prometheus', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_prometheus(spec) - self._orchestrator_wait([completion]) - return HandleCommandResult(stdout=completion.result_str()) - - @_cli_write_command( - 'orch daemon add node-exporter', - 'name=placement,type=CephString,req=false', - 'Add node-exporter daemon(s)') - def _daemon_add_node_exporter(self, placement=None): - spec = ServiceSpec( - 'node-exporter', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_node_exporter(spec) - self._orchestrator_wait([completion]) - return HandleCommandResult(stdout=completion.result_str()) - - @_cli_write_command( - 'orch daemon add crash', - 'name=placement,type=CephString,req=false', - 'Add node-exporter daemon(s)') - def _daemon_add_crash(self, placement=None): - spec = ServiceSpec( - 'crash', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_crash(spec) - self._orchestrator_wait([completion]) - return HandleCommandResult(stdout=completion.result_str()) - - @_cli_write_command( - 'orch daemon add grafana', - 'name=placement,type=CephString,req=false', - 'Add grafana daemon(s)') - def _daemon_add_grafana(self, placement=None): - # type: (Optional[str]) -> HandleCommandResult - spec = ServiceSpec( - 'grafana', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_grafana(spec) - self._orchestrator_wait([completion]) - return HandleCommandResult(stdout=completion.result_str()) - - @_cli_write_command( - 'orch daemon add alertmanager', - 'name=placement,type=CephString,req=false', - 'Add alertmanager daemon(s)') - def _daemon_add_alertmanager(self, placement=None): - # type: (Optional[str]) -> HandleCommandResult - spec = ServiceSpec( - 'alertmanager', - placement=PlacementSpec.from_string(placement), - ) - completion = self.add_alertmanager(spec) - self._orchestrator_wait([completion]) - return HandleCommandResult(stdout=completion.result_str()) - @_cli_write_command( 'orch', "name=action,type=CephChoices,strings=start|stop|restart|redeploy|reconfig "