Examples of managers

The managers are defined as a Python class which inherits from MarcoManager.

An example of a Manager
class DemoManager(MarcoManager):

        __disable__ = True # Set to true if the service is not to be included

        @run_on_executor
        def onSetup(self):
                """
                Actions to include on setup
                """
                nodes = marco.request_for("service")
                for node in nodes:
                        do_something_with_node(node)

        def delay(self):
                """
                Returns delay in seconds after startup.
                """
                return 5

        def onStop(self):
                """
                Actions to be executed befor stopping
                """
                print("Killing")

        def onReload(self):
                """
                Actions when the reload event is fired
                """
                nodes = marco.request_for("service")
                for node in nodes:
                        do_something_with_node(node)

        def doReload(self):
                """
                Periodical reload interval
                """
                return 0

Here are several examples:

class managers.CompilerDiscover[source]

Bases: marcomanager.marcomanager.MarcoManager

Uses MarcoPolo through the Marco python binding to discover the available distcc compilers on the network. If successful, it modifies the /etc/distcc/hosts with the results.

This manager is executed with a delay of 10 seconds after startup and reloads every hour.

delay()[source]

Returns 10, the number of seconds to wait

doReload()[source]

Schedules a reload every 3600 seconds (an hour)

onReload()[source]

On reload, requests again for the compiler service, and dumps the results to the hosts file.

onSetup(*args, **kwargs)[source]

Sends a Request_for message asking for nodes with the compiler service. If successful, it dumps the results to the ‘/etc/distcc/hosts file’

onStop()[source]

Nothing is done

class managers.HostnameManager[source]

Bases: marcomanager.marcomanager.MarcoManager

Includes hostname information in marcopolo