From: Kefu Chai Date: Fri, 26 Feb 2021 03:47:11 +0000 (+0800) Subject: mgr/prometheus: implement command using CLIReadCommand X-Git-Tag: v17.1.0~2710^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3b9ecd14d7d714be7a7c72fa3d44d7781d360135;p=ceph.git mgr/prometheus: implement command using CLIReadCommand Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index e83f9191b11..0f4048391f5 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -9,7 +9,7 @@ import re import socket import threading import time -from mgr_module import MgrModule, MgrStandbyModule, PG_STATES, Option, ServiceInfoT +from mgr_module import CLIReadCommand, MgrModule, MgrStandbyModule, PG_STATES, Option, ServiceInfoT from mgr_util import get_default_addr, profile_method from rbd import RBD from collections import namedtuple @@ -242,14 +242,6 @@ class MetricCollectionThread(threading.Thread): class Module(MgrModule): - COMMANDS = [ - { - "cmd": "prometheus file_sd_config", - "desc": "Return file_sd compatible prometheus config for mgr cluster", - "perm": "r" - }, - ] - MODULE_OPTIONS = [ Option( 'server_addr' @@ -1180,7 +1172,11 @@ class Module(MgrModule): return ''.join(_metrics) + '\n' + @CLIReadCommand('prometheus file_sd_config') def get_file_sd_config(self): + ''' + Return file_sd compatible prometheus config for mgr cluster + ''' servers = self.list_servers() targets = [] for server in servers: @@ -1203,13 +1199,6 @@ class Module(MgrModule): self.collect() self.get_file_sd_config() - def handle_command(self, inbuf, cmd): - if cmd['prefix'] == 'prometheus file_sd_config': - return self.get_file_sd_config() - else: - return (-errno.EINVAL, '', - "Command not found '{0}'".format(cmd['prefix'])) - def serve(self): class Root(object):