From 4287066e13e589fc98b4dfb5fc4683d5a2e04468 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 27 Jan 2021 12:26:42 +0800 Subject: [PATCH] mgr/zabbix: use Option for adding options more type safety Signed-off-by: Kefu Chai --- src/pybind/mgr/zabbix/module.py | 51 +++++++++++++++------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index d427038fa310..74ebf7a277ff 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -9,7 +9,7 @@ import errno import re from subprocess import Popen, PIPE from threading import Event -from mgr_module import MgrModule +from mgr_module import MgrModule, Option def avg(data): @@ -60,33 +60,28 @@ class Module(MgrModule): for o in self.MODULE_OPTIONS) MODULE_OPTIONS = [ - { - 'name': 'zabbix_sender', - 'default': '/usr/bin/zabbix_sender' - }, - { - 'name': 'zabbix_host', - 'default': None - }, - { - 'name': 'zabbix_port', - 'type': 'int', - 'default': 10051 - }, - { - 'name': 'identifier', - 'default': "" - }, - { - 'name': 'interval', - 'type': 'secs', - 'default': 60 - }, - { - 'name': 'discovery_interval', - 'type': 'count', - 'default': 100 - } + Option( + name='zabbix_sender', + default='/usr/bin/zabbix_sender'), + Option( + name='zabbix_host', + type='str', + default=None), + Option( + name='zabbix_port', + type='int', + default=10051), + Option( + name='identifier', + default=""), + Option( + name='interval', + type='secs', + default=60), + Option( + name='discovery_interval', + type='count', + default=100) ] COMMANDS = [ -- 2.47.3