{
    "name"  : "wan口up",
    "precondition" : [],
    "problems" : {
        "no_port_up" : {
            "desc"      : "【问题】当前出口线路均是down，请检查线路是否存在松动或者是否配置了dldp链路检测",
            "advice"    : "【建议】开启出口线路"
        }
    }
}

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

isProblemFound = false

#getInterfaceInfo
res = cli("show html interface info")
#print res
interface_info = formatInterfaceInfo(res)
#print interface_info
set_share_value('interface_info', interface_info)
#log_(interface_info)


#getWansInfo
wan_int_info = []
foreach int in interface_info:
    if int == undefined :
        continue
    end
    #print int.type
    if int.type == 'WAN' :
        wan_int_info.push(int);
    end
end

#print wan_int_info
set_share_value('wan_int_info', wan_int_info)

#getWansInfo
lan_int_info = []
foreach int in interface_info:
    if int == undefined :
        continue
    end
    #print int.type
    if int.type == 'LAN' :
        lan_int_info.push(int);
    end
end

#print lan_int_info
set_share_value('lan_int_info', lan_int_info)



#getWansDetailMap
details = {}
foreach int in wan_int_info:
    #print int
    cmd = "show run interface " + int.intf
    run_int_info = cli(cmd)
    #print run_int_info

    data = formatWanDetail(run_int_info)
    details[int.intf] = data
end
#log_err(details,'----------------------')

#getDisNextHopMap
nexthopMap = {}
foreach int in wan_int_info:
    #print int
    intf = int.intf
    to_lowercase = toLowerCase(intf)
    reg = /di/im
    matchStr = reg.exec(to_lowercase)
    if  matchStr == null:
        continue
    end

    cmd = "show ip route | include " + intf.replace("Di", "dialer ")
    run_int_info = cli(cmd)

    data = formatDisNextHop(run_int_info)
    nexthopMap[int.intf] = data

end
#log_err(nexthopMap,'nexthopMap----------------------')


#getIpsRefAbjMap
ipRefAbjMap = {}
foreach int in wan_int_info:
    #print int
    cmd = 'show ip ref adj int ' + int.intf + ' | include resolved'
    run_int_info = cli(cmd)
    #print run_int_info

    data = formatIpsRefAbjMap(run_int_info)
    ipRefAbjMap[int.intf] = data
end

#log_err(ipRefAbjMap,'ipRefAbjMap----------------------')

#getWansInfo
wansDetail = getWansInfo(wan_int_info, details,nexthopMap, ipRefAbjMap)
set_share_value('wansDetail', wansDetail)

#getLansDetailMap

lan_details = {}
foreach int in lan_int_info:
    #print int
    cmd = "show run interface " + int.intf
    run_int_info = cli(cmd)
    #print run_int_info

    data = formatLanDetail(run_int_info)
    lan_details[int.intf] = data
end
#log_err(details,'----------------------')

#getNoBufferMap
lan_bussers = {}
foreach int in lan_int_info:
    #print int
    cmd = "show interface " + int.intf + " | include no buffer"
    run_int_info = cli(cmd)
    #print run_int_info

    data = formatBusser(run_int_info)
    lan_bussers[int.intf] = data
end
lansDetail = getLansInfo(lan_int_info, lan_details,lan_bussers)
set_share_value('lansDetail', lansDetail)


isUP = false
foreach data in wan_int_info :
    if data.isUP && data.ip :
        isUp = true
        break
    end
end

if isUp :
    return 'success'
end

isProblemFound = true
add_problem("no_port_up");

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