Пример #1
0
def start_powercycle(device_name, callback, max_time=30):
    """
    Initiate a power cycle for DEVICE_NAME.  This function returns immediately,
    and will invoke CALLBACK with a boolean success indication when the
    operation is complete.  CALLBACK will be invoked in a different thread from
    that where this function was called.

    The function guarantees to callback before MAX_TIME seconds have elapsed,
    or not call back at all.
    """
    callback_before = time.time() + max_time

    hostname, bnk, rly = data.device_relay_info(device_name)

    logs.device_logs.add(device_name, "initiating power cycle", 'bmm')
    _run_async(callback_before, callback, lambda : relay.powercycle(hostname, bnk, rly, max_time))
Пример #2
0
def start_powercycle(device_name, callback, max_time=30):
    """
    Initiate a power cycle for DEVICE_NAME.  This function returns immediately,
    and will invoke CALLBACK with a boolean success indication when the
    operation is complete.  CALLBACK will be invoked in a different thread from
    that where this function was called.

    The function guarantees to callback before MAX_TIME seconds have elapsed,
    or not call back at all.
    """
    callback_before = time.time() + max_time

    hostname, bnk, rly = data.device_relay_info(device_name)

    logs.device_logs.add(device_name, "initiating power cycle", 'bmm')
    _run_async(callback_before, callback,
               lambda: relay.powercycle(hostname, bnk, rly, max_time))
Пример #3
0
    def on_entry(self):
        has_sut_agent = data.device_has_sut_agent(self.machine.device_name)
        has_relay = data.device_relay_info(self.machine.device_name)
        if has_sut_agent and (not has_relay or
                              (self.machine.increment_counter('sut_attempts') <=
                               self.TRY_RELAY_AFTER_SUT_COUNT)):
            self.sut_reboot()
            return

        if has_relay:
            self.relay_powercycle()
        else:
            if has_sut_agent:
                self.logger.error('cannot power-cycle device: SUT reboot '
                                  'failed and no relay')
            else:
                self.logger.error('cannot power-cycle device: no relay nor '
                                  'SUT agent')
            self.machine.goto_state(failed_power_cycling)
Пример #4
0
 def testRelayInfo(self):
     self.assertEquals(("relay-1", 1, 1),
                       data.device_relay_info("device1"))