Project

General

Profile

Bug #41040 » module.py

module.py for ceph/src/pybind/mgr/minimal - Ali Maredia, 07/31/2019 08:51 PM

 
"""
A minimal module
"""

from mgr_module import MgrModule
from threading import Event

class Minimal(MgrModule):
# these are CLI commands we implement
COMMANDS = []

# 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 = []

def __init__(self, *args, **kwargs):
super(Minimal, self).__init__(*args, **kwargs)

# set up some members to enable the serve() method and shutdown
self.run = True
self.event = Event()

def serve(self):
"""
This method is called by the mgr when the module starts and can be
used for any background activity.
"""
self.log.info("Starting")
status = self.get_daemon_status("osd", 0)
self.log.info('Daemon status is: {status}'.format(status=status))
while self.run:
sleep_interval = 5
self.log.debug('Sleeping for %d seconds', sleep_interval)
ret = self.event.wait(sleep_interval)
self.event.clear()

def shutdown(self):
"""
This method is called by the mgr when the module needs to shut
down (i.e., when the serve() function needs to exit.
"""
self.log.info('Stopping')
self.run = False
self.event.set()
(1-1/2)