Exemplo n.º 1
0
def start_ping(device_name, callback):
    """
    Begin pinging the device (using its fqdn, thus depending on DNS as well).
    The callback will be invoked with a boolean success flag within ten seconds.
    """
    callback_before = time.time() + 10
    fqdn = data.device_fqdn(device_name)
    def do_ping():
        pingable = ping_module.ping(fqdn)
        logs.device_logs.add(device_name, "ping of %s complete: %s" % (fqdn, 'ok' if pingable else 'failed'), 'bmm')
        return pingable
    run_async(callback_before, callback, do_ping, logger)
Exemplo n.º 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), logger)
Exemplo n.º 3
0
def start_check_sdcard(device_name, callback):
    logger.info('Starting SD-card check.')
    logs.device_logs.add(device_name, 'verifying SD card', 'sut')
    run_async(None, callback,
              lambda: cli.check_sdcard(data.device_fqdn(device_name)), logger)
Exemplo n.º 4
0
def start_sut_verify(device_name, callback):
    logger.info('Verifying SUT agent.')
    logs.device_logs.add(device_name, 'connecting to SUT agent', 'sut')
    run_async(None, callback,
              lambda: cli.sut_verify(data.device_fqdn(device_name)), logger)
Exemplo n.º 5
0
def start_reboot(device_name, callback):
    logger.info('Starting reboot.')
    logs.device_logs.add(device_name, 'starting reboot', 'sut')
    run_async(None, callback,
              lambda: cli.reboot(data.device_fqdn(device_name)), logger)