From 9c20e3961f4066f85fa90257f486bac988b7ce4c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Feb 2020 13:13:55 -0600 Subject: [PATCH] mgr/orch: add prom hooks Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator.py | 10 ++++++++ src/pybind/mgr/orchestrator_cli/module.py | 30 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 6a6ae995961..f098cf759d1 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -1011,6 +1011,16 @@ class Orchestrator(object): """Update RGW cluster""" raise NotImplementedError() + def add_prometheus(self, spec): + # type: (ServiceSpec) -> Completion + """Create new prometheus daemon""" + raise NotImplementedError() + + def apply_prometheus(self, spec): + # type: (ServiceSpec) -> Completion + """Update prometheus cluster""" + raise NotImplementedError() + def upgrade_check(self, image, version): # type: (Optional[str], Optional[str]) -> Completion raise NotImplementedError() diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 09762d21b66..204a6638b98 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -500,6 +500,21 @@ Usage: orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( + 'orch daemon add prometheus', + 'name=num,type=CephInt,req=false ' + 'name=hosts,type=CephString,n=N,req=false ' + 'name=label,type=CephString,req=false', + 'Add prometheus daemon(s)') + def _daemon_add_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.add_prometheus(spec) + self._orchestrator_wait([completion]) + return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( 'orch', "name=action,type=CephChoices,strings=start|stop|restart|redeploy|reconfig " @@ -668,6 +683,21 @@ Usage: self._orchestrator_wait([completion]) return HandleCommandResult(stdout=completion.result_str()) + @orchestrator._cli_write_command( + 'orch apply prometheus', + 'name=num,type=CephInt,req=false ' + 'name=hosts,type=CephString,n=N,req=false ' + 'name=label,type=CephString,req=false', + 'Scale prometheus service') + 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()) + @orchestrator._cli_write_command( 'orch set backend', "name=module_name,type=CephString,req=true", -- 2.39.5