{
    "name"  : "多链路负载均衡",
    "precondition" : [],
    "problems" : {
        "mllb" : {
            "desc"      : "【问题】当前为多出口环境，建议开启多链路负载均衡功能，可以改善出口带宽的使用均衡",
            "advice"    : [
                "【建议】可运行如下配置进行修复", 
                "配置示例：",
                "Ruijie#config",
                "Ruijie(config)#mllb enable",
                "Ruijie(config)#mllb policy bandwidth",
                "Ruijie(config)#mllb load-sharing original",
                "Ruijie(config)#end",
                "Ruijie#write"              
            ]
        },
        "mllb1" : {
            "desc"      : "【问题】请使用基于带宽的负载均衡，当前有可能会存在网银或者游戏掉线",
            "advice"    : [
                "【建议】可运行如下配置进行修复", 
                "配置示例：",
                "Ruijie#config",
                "Ruijie(config)#mllb enable",
                "Ruijie(config)#mllb policy bandwidth",
                "Ruijie(config)#mllb load-sharing original",
                "Ruijie(config)#end",
                "Ruijie#write"               
            ]
        },
        "mllb2" : {
            "desc"      : "【问题】请使用基于源ip地址哈希的负载均衡，当前有可能会存在网银或者游戏掉线",
            "advice"    : [
                "【建议】可运行如下配置进行修复", 
                "配置示例：",
                "Ruijie#config",
                "Ruijie(config)#mllb enable",
                "Ruijie(config)#mllb load-sharing original",
                "Ruijie(config)#end",
                "Ruijie#write"               
            ]
        }
    }
}

---------------------------code-------------------------------

isProblemFound = false
wansDetail = get_share_value('wansDetail')

res = cli("show mllb configure")
config = formatMllbConfig(res)

isMultiOutIntf = false

num = 0
foreach wan in wansDetail:
    if wan.isUP && wan.ip :
        num = num + 1
        if num == 2:
            isMultiOutIntf = true
            break   
        end
        
    end
end
set_share_value('mllbCfg', config)
set_share_value('isMultiOutIntf', isMultiOutIntf)


mllbEnable = config.stateEnable
mllbBandWidth = config.policyBandWidth
mllbLoadSharing = config.policyLoadSharing

if !mllbEnable && isMultiOutIntf :
    isProblemFound = true
    add_problem("mllb")
    return 'warn'
end
if mllbEnable && !mllbBandWidth :
    isProblemFound = true
    add_problem("mllb1")
    return 'warn'
end
if mllbEnable && !mllbLoadSharing :
    isProblemFound = true
    add_problem("mllb2")
    return 'warn'
end


if isProblemFound == true :
    return 'warn'
else:
    return 'success'
end
