Beispiel #1
0
    def try_start_testing(self, host_id, claim_id):
        with self._lock:
            host = self._hostlist.get_by_id(host_id)
            if host:
                if host.get_state() == FSMStates.AF_TESTING:
                    log.msg('Host already in Start Testing state')
                    return

                event = HostEvent(FSMEvents.AE_START_TESTING, claim_id)
                host.send_event(event)
Beispiel #2
0
    def reclaim_host(self, host_id, claim_id):
        with self._lock:
            host = self._hostlist.get_by_id(host_id)
            if host:
                reclaim_event = HostEvent(FSMEvents.AE_RECLAIM, claim_id)
                accepted = host.send_event(reclaim_event)
                if accepted:
                    return host

            return None
Beispiel #3
0
    def schedule(self, host_id, claim_id, test_script):
        with self._lock:
            host = self._hostlist.get_by_id(host_id)
            if host:
                schedule_event = HostEvent(FSMEvents.AE_SCHEDULE_TEST,
                                           test_script)
                accepted = host.send_event(schedule_event)
                if accepted:
                    return host

            return None
Beispiel #4
0
 def execution_done(self, hostname):
     with self._lock:
         host = self._hostlist.get_by_hostname(hostname)
         if host:
             event = HostEvent(FSMEvents.AE_STOP_TESTING)
             host.send_event(event)
Beispiel #5
0
    def set_alive(self, alive):
        super(DynamicHost, self).set_alive(alive)

        with self._lock:
            if alive == HostAlive.HA_ALIVE:
                self._fsm.execute(HostEvent(FSMEvents.AE_WAKE))
Beispiel #6
0
    def decrease_age(self):
        super(DynamicHost, self).decrease_age()

        with self._lock:
            if self._age == 0:
                self._fsm.execute(HostEvent(FSMEvents.AE_DEMISE))