summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2018-12-21 15:55:34 +0100
committerSage Weil <sage@redhat.com>2018-12-21 15:55:34 +0100
commit97fa74e7c0e888ea6946d5481565997d58fb0f61 (patch)
treeef889f747c3ba904595aba06672b0bacfbe40a27
parentpybind/mgr/mgr_module: normalize defaults to str when type is missing (diff)
downloadceph-97fa74e7c0e888ea6946d5481565997d58fb0f61.tar.xz
ceph-97fa74e7c0e888ea6946d5481565997d58fb0f61.zip
mgr/hello: define some module options
Signed-off-by: Sage Weil <sage@redhat.com>
-rw-r--r--src/pybind/mgr/hello/module.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/pybind/mgr/hello/module.py b/src/pybind/mgr/hello/module.py
index e110e8c441d..08d0bf4802c 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/<name> <value>'. 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