]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/hello: define some module options 25597/head
authorSage Weil <sage@redhat.com>
Fri, 21 Dec 2018 14:55:34 +0000 (08:55 -0600)
committerSage Weil <sage@redhat.com>
Fri, 21 Dec 2018 14:55:34 +0000 (08:55 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/hello/module.py

index e110e8c441dceec24aab9ccdae7212704b387b12..08d0bf4802cada109ab88a997ddaf32a2d90ff64 100644 (file)
@@ -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