{
    "name"  : "DHCP服务是否使能",
    "problems" : {
        "dhcp" : {
            "desc"      : "【问题】DHCP服务未使能",
            "advice"    : ["【建议】使能DHCP服务 "
                        ,"配置示例："
                        ,"\tRuijie#config"
                        ,"\tRuijie(config)#serivce dhcp"
                        ,"\tRuijie(config)#end"
                        ,"\tRuijie#write"]
        }
    }
}
---------------------------code-------------------------------# @fanbh 该规则与文档出入较大，是否提供修订后的文档？
#DHCP服务是否使能
param = {}
param["role"] = precondition('role')
no_support_dev = false
deviceMode = get_device_model()
if deviceMode == 'RG-S2900G-E/P' || deviceMode == 'RG-S2600G-I' :
    no_support_dev = true
end
def checkService():
    if no_support_dev :
        return "success"
    end
    if role == "server" || role == "relay" :
        response = cli('show run | include service dhcp')
        results = response.split(/\r?\n/ig)
        exist = false
        i = 1
        while i < results.length:    # @fanbh 这边有必要去拆成数组再一个一个的找呢？直接输出内容进行search不是更简洁？
            resultTmp = results[i]
            if resultTmp.search("service dhcp") != -1:
                exist = true
                break
            end
            i = i + 1
        end
        if exist == false:
            add_problem(dhcp)   # @fanbh dhch作为参数未加"",另外，文档中的建议是自动修复，缺少自动修复的操作
            return "warn"
        end
        return "success"
    else :
        return "success"
    end
end

role = param["role"]
if role == "server" :
    response = cli('show version slots')
    results = response.split(/\r?\n/ig)
    exist = false
    i = 1
    while i < results.length:    # @fanbh 这边有必要去拆成数组再一个一个的找呢？直接输出内容进行search不是更简洁？
        resultTmp = results[i]
        if resultTmp.search("RG-S2900G-E/P") != -1 :
            exist = true
        end
        if resultTmp.search("RG-S2600G-I") != -1 :
            exist = true
            break
        end    
        i = i + 1
    end
    if exist == true:
        no_support_dev = true
    end
    ret = checkService()
    return ret
else :
    ret = checkService()
    return ret
end




