{
    "name"  : "dot1x获取IP后计费功能依赖配置检查",
    "problems" : {
        "verdion_skip" : {
            "desc"      : "",
            "advice"    : "【提示】检查出非无线设备版本,不进行配置检查"
        },
        "getversion_fail" : {
            "desc"      : "【问题】获取版本号失败",
            "advice"    : "【建议】手动show version detail查看版本号是否存在"
        },
        "should_warm" : {
            "desc"      : "【告警】无线802.1X开启了获取IP后计费功能,该功能依赖dhcp snooping配置,请确认是否可以开启dhcp snooping,否则请将802.1X获取IP后计费功能关闭,避免影响用户使用网络!",
            "advice"    : ""
        },
        "warm_skip" : {
            "desc"      : "",
            "advice"    : "【提示】不存在dot1x获取IP后计费功能未同时开ip dhcp snooping问题"
        }
    }
}
---------------------------code-------------------------------
precondition_result = 'pass'
precondition_message = ''
precondition_message_advice = ''

#执行log
log_version = cli('show version detail')
log_versionList = log_version.split('\r\n')

#判断是否无线设备版本
if !isWlanVersion():
    precondition_result = 'fail'
	precondition_message = '检测出非无线设备版本'
	precondition_message_advice = '检测出非无线设备版本'
	set_share_value('precondition_result',precondition_result)
	set_share_value('precondition_message',precondition_message)
	set_share_value('precondition_message_advice',precondition_message_advice)
	add_problem('verdion_skip')
    return 'success'
end

if shouldWarn():
    add_problem('should_warm')
    return 'warn'
else:
    add_problem('warm_skip')
    return 'success'
end

#判断是否无线设备版本
def isWlanVersion():
	result = 0
    #库函数
    version = get_device_softvesion()
    if version == null || version == '':
        add_problem('getversion_fail')
        return 'warn'
    end
    if version.indexOf("11.1(5)") != -1:
        result = 1
    end
    
	return result
end

#判断是否需要告警
def shouldWarn():
    result = 0
    log_dot1x = cli('show dot1x ability')
    if log_dot1x.match(/Wlan User Valid-IP-Acct Check ..* N/g) != null:
        result = 0
    else:
        log_run = cli('show run')
        if log_run.indexOf('dot1x valid-ip-acct enable')!=-1 && log_run.indexOf('ip dhcp snooping')==-1:
            result = 1
        end
    end
    return result
end