def __init__(self, name):
        """
        This is the default constructor for the class.

        :param name:            The name of the process needing the iface.
        :return:
        """

        # Set the name
        self.__name = name

        # Set the queue from the resource manager
        self.__queue = get_client_manager().get_queue(
            name
        )

        # Set the logger
        self.__logger  = logging.getLogger(
            "LogStashForwarder"
            + " - "
            + self.__name
        )

        # Override the super class
        Process.__init__(self)
        return
示例#2
0
    def register(self, name, entry, configs):
        """
        Register the application within the plugin.

        :param name:                The name of the app
        :param entry:               The entry point of the app
        :param configs:             The configs for the app
        :return:
        """

        temp = dict()

        # Create the application queue
        temp['queue'] = Queue()

        # Create a publisher
        temp['pub'] = NodePublisher(
            NodePublisher.format_url(
                configs['COMS']
            ),
            temp['queue'],
            name,
            configs['name']
        )

        # Create the managed resource
        temp['resource'] = ManagedResource(
            name = name,
            tag = configs['name']
        )

        # Register the entry point of the app
        temp['entry'] = entry

        # We need to register the new queue for this probe
        self.__manager.add_queue(
            configs['name']
        )

        # Register the resource client handle
        temp['client'] = get_client_manager()

        # Add the app in the app db
        self.__apps[
            configs['name']
        ] = temp

        self._logger.info(
            "[+] Added a new probe: {name}".format(
                name = configs['name']
            )
        )
        return