Пример #1
0
def check(args):
    """
    Checks that the specified device is configured correctly

    Args:
        args (configuration object): Program command line arguments

    Returns:
        Tuple (Bool, String): Test status code and result message string. True
        indicates tests passed succesfully, false indicates that there were
        failures
    """

    if not args.device:
        raise errors.AFTConfigurationError(
            "You must specify the device that will be checked")

    if args.verbose:
        print("Running configuration check on " + args.device)

    if args.checkall:
        logger.init_thread(args.device + "_")

    logger.info("Running configuration check on " + args.device)

    manager = DevicesManager(args)
    device = manager.reserve_specific(args.device)

    if args.verbose:
        print("Device " + args.device + " acquired, running checks")

    try:
        sanity_results = _run_sanity_tests(args, device)
        image_test_results = (True, "Image Test result: Not run")
        # only run image test if sanity test passed
        if sanity_results[0] == True:
            image_test_results = _run_tests_on_know_good_image(args, device)

    finally:
        if args.verbose:
            print("Releasing device " + args.device)

        if not args.nopoweroff:
            device.detach()

        manager.release(device)

    results = (sanity_results[0] and image_test_results[0],
               sanity_results[1] + "\n" + image_test_results[1])

    if not results[0]:
        common.blacklist_device(device.dev_id, args.device,
                                "Failed device health check")
        msg = "Device " + args.device + " failed health test - blacklisting"
        logger.info(msg)
        if args.verbose:
            print msg

    return results
Пример #2
0
def check(args):
    """
    Checks that the specified device is configured correctly

    Args:
        args (configuration object): Program command line arguments

    Returns:
        Tuple (Bool, String): Test status code and result message string. True
        indicates tests passed succesfully, false indicates that there were
        failures
    """

    if not args.device:
        raise errors.AFTConfigurationError(
            "You must specify the device that will be checked")

    if args.verbose:
        print "Running configuration check on " + args.device

    logging.info("Running configuration check on " + args.device)
    manager = DevicesManager(args)
    device = manager.reserve_specific(args.device)

    if args.verbose:
        print "Device " + args.device + " acquired, running checks"

    test_results = _run_tests(args, device)


    if args.verbose:
        print "Releasing device " + args.device

    manager.release(device)
    results =  _handle_test_results(args, device, test_results)

    if not results[0]:
        common.blacklist_device(
                device.dev_id,
                args.device,
                "Failed device health check")

        msg = "Device " + args.device + " failed health test - blacklisting"
        logging.info(msg)
        if args.verbose:
            print msg


    return results
Пример #3
0
def check(args):
    """
    Checks that the specified device is configured correctly

    Args:
        args (configuration object): Program command line arguments

    Returns:
        Tuple (Bool, String): Test status code and result message string. True
        indicates tests passed succesfully, false indicates that there were
        failures
    """

    if not args.device:
        raise errors.AFTConfigurationError(
            "You must specify the device that will be checked")

    if args.verbose:
        print("Running configuration check on " + args.device)

    if args.checkall:
        logger.init_thread(args.device + "_")

    logger.info("Running configuration check on " + args.device)

    manager = DevicesManager(args)
    device = manager.reserve_specific(args.device)

    if args.verbose:
        print("Device " + args.device + " acquired, running checks")

    try:
        sanity_results = _run_sanity_tests(args, device)
        image_test_results = (True, "Image Test result: Not run")
        # only run image test if sanity test passed
        if sanity_results[0] == True:
            image_test_results = _run_tests_on_know_good_image(args, device)

    finally:
        if args.verbose:
            print("Releasing device " + args.device)

        if not args.nopoweroff:
            device.detach()

        manager.release(device)

    results = (
        sanity_results[0] and image_test_results[0],
        sanity_results[1] + "\n" + image_test_results[1]
        )

    if not results[0]:
        common.blacklist_device(
                device.dev_id,
                args.device,
                "Failed device health check")
        msg = "Device " + args.device + " failed health test - blacklisting"
        logger.info(msg)
        if args.verbose:
            print msg

    return results