def lfs_migrate()

in FSxL-Compression/fsx_lustre_migrate_files.py [0:0]


def lfs_migrate(file_path):
    cmd = ["/usr/bin/lfs", "migrate"]
    is_PFL, stripe_configuration = parse_stripe_configuration(file_path)
    if is_PFL:
        for extend_configuration in stripe_configuration:
            cmd.append("-E")
            cmd.append(str(extend_configuration["end_bytes"]))
            cmd.append("-c")
            cmd.append(str(extend_configuration["lmm_stripe_count"]))
            cmd.append("-S")
            cmd.append(str(extend_configuration["lmm_stripe_size"]))
    else:
        cmd.append("-c")
        cmd.append(str(stripe_configuration["lmm_stripe_count"]))
        cmd.append("-S")
        cmd.append(str(stripe_configuration["lmm_stripe_size"]))
    cmd.append(file_path)
    p = subprocess.run(cmd, stdout=DEVNULL, stderr=PIPE)
    if p.returncode > 0:
        logger.error("lfs migrate failed for file: " + file_path)
        logger.error(p.stderr)
        sys.exit(p.returncode)
    logger.info("lfs migrate completed for file: %s", file_path)