#!/usr/bin/env python

import sys

import isi.hw.drive_mfg_check as drivecheck
import isi.hw.bootstrap as bootstrap

def main(argv):

    dc = drivecheck.DriveMfgCheck(verbose=True)

    # Check data drives
    num_failures = dc.get_num_failures()

    # Check boot drives
    if not bootstrap.isInfinityMotherboard():
        boot_drives = bootstrap.getEligibleBootdiskDeviceNames()
        for boot_drive in boot_drives:
            bd_fail = dc.check_boot_drive(boot_drive)
            num_failures += len(set(bd_fail))

    # Journal drives
    journal_drives = bootstrap.getInfinityPmpDeviceNames()
    if journal_drives is not None:
        for drive in journal_drives:
            if not len(drive):
                continue
            journal_fail = dc.check_internal_drive(drive)
            num_failures += len(set(journal_fail))

    sys.exit(num_failures)

if __name__ == "__main__":
    main(sys.argv[:])
