Exemplo n.º 1
0
    def exitAll(self, timeout=10):
        """
        Called to tell the director to shutdown stopped ALL
        controllers and child processes.

        :param timeout: This is the amount of time (in seconds)
        used to wait for the director to respond. If a response
        isn't received within this then SignalTimeout will be
        raised.

        Event Dispatched: EVT_DIRECTOR_EXIT_ALL

        """
        sig = messenger.EVT("EVT_DIRECTOR_EXIT_ALL")
        self.log.warn("exitAll: (request sig id %s) shutdown signal received!" % sig.uid)
        try:
            rc = messenger.send_await(sig, timeout=timeout)

        except messenger.EventTimeout:
            raise SignalTimeout("exitAll: Director presence check failed! Is it running?")

        else:
            self.log.debug("exitAll: (request sig id %s) shutting down." % sig.uid)
            rc = rc['data']

        return rc
Exemplo n.º 2
0
    def ping(self, timeout=10, testing=None):
        """
        Called to check if the director is actually there and
        responding, otherwise we could be waiting forever for
        nothing to happen.

        :param timeout: This is the amount of time (in seconds)
        used to wait for the director to respond. If a response
        isn't received within this then SignalTimeout will be
        raised.

        Event Dispatched: EVT_DIRECTOR_PING

        """
        token = str(uuid.uuid4())
        self.log.debug("ping: waiting for director with token '%s'." % (token))
        sig = messenger.EVT("EVT_DIRECTOR_PING")
        if testing:
            # use the unittest's EVT_DIRECTOR_PING instead.
            sig = testing
        try:
            rc = messenger.send_await(sig, token, timeout=timeout)
            rtoken = rc['data']['data']
            if token != rtoken:
                self.log.warn("ping: received ping token '%s' is different to '%s'" % (token, rtoken))
            else:
                self.log.debug("ping: received correct ping from director." % ())

        except messenger.EventTimeout:
            raise SignalTimeout("Director presence check failed! Is it running?")
Exemplo n.º 3
0
    def configuration(self, timeout=DEFAULT_TIMEOUT):
        """
        Called to return the director configuration.

        :param timeout: This is the amount of time (in seconds)
        used to wait for the director to respond. If a response
        isn't received within this then SignalTimeout will be
        raised.

        :returns: See SignalReceiver configuration.

        Event Dispatched: EVT_DIRECTOR_CONFIGURATION

        """
        sig = messenger.EVT("EVT_DIRECTOR_CONFIGURATION")
        try:
            self.log.debug("configuration: (request sig id %s) getting director configuration." % sig.uid)
            rc = messenger.send_await(sig, timeout=timeout)

        except messenger.EventTimeout:
            self.log.error("configuration: (request sig id %s) event timeout!" % sig.uid)
            raise SignalTimeout("Director communication timeout (%s)s! Is it running?" % timeout)

        else:
            self.log.debug("configuration: (reply for sig id %s) configuration recovered ok." % sig.uid)
            rc = rc['data']

        return rc
Exemplo n.º 4
0
    def controllerStop(self, name, timeout=DEFAULT_TIMEOUT):
        """
        Called to tell a controller to stop running.

        :param name: This will contain the name of the controller
        to be started. This name is the same name as that in the
        configuration section.

        :param timeout: This is the amount of time (in seconds)
        used to wait for the director to respond. If a response
        isn't received within this then SignalTimeout will be
        raised.

        :returns: See SignalReceiver controllerStop.

        Event Dispatched: EVT_DIRECTOR_CTRLSTOP

        """
        sig = messenger.EVT("EVT_DIRECTOR_CTRLSTOP")
        try:
            self.log.debug("controllerStop: (request sig id %s) stopping controller." % sig.uid)
            rc = messenger.send_await(sig, name, timeout=timeout)

        except messenger.EventTimeout:
            self.log.error("controllerStop: (request sig id %s) event timeout!" % sig.uid)
            raise SignalTimeout("Director communication timeout (%s)s! Is it running?" % timeout)

        else:
            self.log.debug("controllerStop: (reply for sig id %s) stop called ok." % sig.uid)
            rc = rc['data']

        return rc
Exemplo n.º 5
0
    def controllerReload(self, name, new_config, timeout=DEFAULT_TIMEOUT):
        """
        Called to tell a controller reload and use the new
        configuration.

        This will stop it if its running, tear it down and replace
        it with whatever the new_config contains.

        :param name: This will contain the name of the controller
        to be started. This name is the same name as that in the
        configuration section.

        :param new_config: This is any valid controller
        configuration

        :param timeout: This is the amount of time (in seconds)
        used to wait for the director to respond. If a response
        isn't received within this then SignalTimeout will be
        raised.

        :returns: See SignalReceiver controllerReload.

        Event Dispatched: EVT_DIRECTOR_CTRLRELOAD

        """
        sig = messenger.EVT("EVT_DIRECTOR_CTRLRELOAD")
        try:
            self.log.debug("controllerReload: (request sig id %s) calling reload." % sig.uid)
            rc = messenger.send_await(sig, [name, new_config], timeout=timeout)

        except messenger.EventTimeout:
            self.log.error("controllerReload: (request sig id %s) event timeout!" % sig.uid)
            raise SignalTimeout("Director communication timeout (%s)s! Is it running?" % timeout)

        else:
            self.log.debug("controllerReload: (reply for sig id %s) reload called ok." % sig.uid)
            rc = rc['data']

        return rc