#!/bin/bash

_install() {
    return 0
}

_check() {
    _check="PASS"

    if [[ $VMFLAG = 1 ]] || [[ $SecUsage = "HW-resourcepool" ]] || [[ $SecUsage = "resourcepool" ]];then
        return 0
    fi

    if [[ $RaidInfo =~ "noraid" ]];then
        local disknum=${RaidInfo:6}
    else
        if [[ $RaidInfo =~ '+' ]];then
            local disknum1=`echo "$RaidInfo"|awk -F'[*+ ]' '{print $3}'`
            local disknum2=`echo "$RaidInfo"|awk -F'[*+ ]' '{print $9}'`
            local disknum=$(($disknum1 + $disknum2))
        else
            local disknum=`echo "$RaidInfo"|awk -F'[*+ ]' '{print $3}'`
        fi
    fi

    # 取系统下数据盘数量，去掉系统盘和磁盘分区
    if [[ $UCLOUD_SYS_DISK_LABEL =~ "nvme" ]];then
        local real_disk=$(lsblk -d|grep -E "^sd|df|nvme"|grep -Pv "nvme0n1"|grep -Ec 'G|T')
    else
        local real_disk=$(lsblk -d|grep -E "^sd|df|nvme"|grep -Pv "sda\b"|grep -Ec 'G|T')
    fi
    if [[ $real_disk -ne $disknum ]];then
        _check="FAIL"
        PRINT_ERR "[ERROR] DataDisk Number Is $real_disk Not $disknum, DataDisk Raid Incorrect."
    else
        _check="PASS"
    fi
}
