From 97fa74e7c0e888ea6946d5481565997d58fb0f61 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 Dec 2018 08:55:34 -0600 Subject: [PATCH] mgr/hello: define some module options Signed-off-by: Sage Weil --- src/pybind/mgr/hello/module.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/hello/module.py b/src/pybind/mgr/hello/module.py index e110e8c441dc..08d0bf4802ca 100644 --- a/src/pybind/mgr/hello/module.py +++ b/src/pybind/mgr/hello/module.py @@ -10,6 +10,7 @@ from threading import Event class Hello(MgrModule): + # these are CLI commands we implement COMMANDS = [ { "cmd": "hello " @@ -19,6 +20,21 @@ class Hello(MgrModule): }, ] + # these are module options we understand. These can be set with + # 'ceph config set global mgr/hello/ '. e.g., + # 'ceph config set global mgr/hello/place Earth' + MODULE_OPTIONS = [ + { + 'name': 'place', + 'default': 'world', + }, + { + 'name': 'emphatic', + 'type': 'bool', + 'default': True, + }, + ] + def __init__(self, *args, **kwargs): super(Hello, self).__init__(*args, **kwargs) @@ -34,10 +50,12 @@ class Hello(MgrModule): status_code = 0 output_buffer = "Output buffer is for data results" output_string = "Output string is for informative text" - message = "hello world!" - if 'person_name' in cmd: - message = "hello, " + cmd['person_name'] + "!" + message = "Hello, " + cmd['person_name'] + else: + message = "Hello " + self.get_module_option('place'); + if self.get_module_option('emphatic'): + message += '!' return status_code, output_buffer, message + "\n" + output_string -- 2.47.3