{
    "name"  : "Virtual-PPP接口配置检查",
    "problems" : {
	    "flowError" : {
            "desc"      : "【问题】没配置任何VP口。",
            "advice"    : "【建议】需要配置VP口才可以拨号。"
        },
        "shutdownError" : {
            "desc"      : "【问题】Virtual-ppp口被shutdown。",
            "advice"    : "【建议】在Virtual-ppp口上执行no shutdown命令。"
        },
		"noIPError" : {
			"desc"      : "【问题】Virtual-ppp口未配置ip地址自协商或者静态IP地址。",
            "advice"    : "【建议】在Virtual-ppp口下面配置ip address negotiate或指定静态IP地址。"
		},
		"noPARError" : {
			"desc"      : "【问题】Virtual-ppp口未配置PAP认证的用户名和密码。",
            "advice"    : "【建议】在Virtual-ppp口下面配置PAP认证的用户名和密码。"
		},
		"noCHAPUserError" : {
			"desc"      : "【问题】Virtual-ppp口未配置CHAP认证的用户名。",
            "advice"    : "【建议】在Virtual-ppp口下面配置CHAP认证的用户名。"
		},
		"noCHARPasswordError" : {
			"desc"      : "【问题】Virtual-ppp口下面未配置CHAP认证的密码。",
            "advice"    : "【建议】在Virtual-ppp口下面配置CHAP认证的密码。"
		},
		"noPseudowireError" : {
			"desc"      : "【问题】Virtual-ppp口下面未配置访问总部的pseudowire命令。",
            "advice"    : "【建议】在Virtual-ppp口下面配置访问总部的pseudowire命令。"
		},
		"cannotPingError" : {
			"desc"      : "【问题】总部IP无法ping通。",
            "advice"    : "【建议】请检查网络环境和配置。"
		}
    }
}
---------------------------code-------------------------------
isServer= precondition('isServer')
print isServer
if isServer == true :
	print 'skip'
	return 'skip'
end
num = 0
i = 0
errorFlag = 0
res = cli("show ip interface brief | inc Virtual-ppp")
print res
resArr = res.match(/Virtual-ppp \d+/ig)
print resArr
if resArr == null :
	print 'warn'
	add_problem("flowError")
	return 'warn'
end
while num < resArr.length :
	commend = "show running-config int "+resArr[num]+ " | inc shutdown"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/shutdown/ig)
	print resConArr
	if resConArr[1] != null :
		print 'warn'
		errorFlag = 1
		add_problem("shutdownError")
	end
	commend = "show run int "+resArr[num]+ " | inc ip address"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/ip address negotiate/ig)
	print resConArr
	if resConArr == null :	
		print 'warn'
		errorFlag = 1
		add_problem("noIPError")
	end

	commend = "show run int "+resArr[num]+ " | inc ppp pap sent-username"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/ppp pap sent-username/ig)
	print resConArr
	if resConArr[1] == null :	
		print 'warn'
		errorFlag = 1
		add_problem("noPARError")
	end

	commend = "show run int "+resArr[num]+ " | inc ppp chap hostname"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/ppp chap hostname/ig)
	print resConArr
	if resConArr[1] == null :	
		print 'warn'
		errorFlag = 1
		add_problem("noCHAPUserError")
	end

	commend = "show run int "+resArr[num]+ " | inc ppp chap password"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/ppp chap password/ig)
	print resConArr
	if resConArr[1] == null :	
		print 'warn'
		errorFlag = 1
		add_problem("noCHARPasswordError")
	end

	commend = "show run int "+resArr[num]+ " | inc pseudowire"
	print commend
	resCon = cli(commend)
	print resCon
	resConArr = resCon.match(/pseudowire/ig)
	print resConArr
	if resConArr[1] == null :	
		print 'warn'
		errorFlag = 1
		add_problem("noPseudowireError")
	end

	if resConArr[1] != null :
		psIP = resCon.match(/\d+\.\d+\.\d+\.\d+/)
		commend = "ping "+ psIP[0]
		print commend
		resCon = cli(commend)
		print resCon
		resCon = cli(commend)
		print resCon
		resConArr = resCon.match(/Success rate is 0 percent/ig)
		print resConArr
		if resConArr != null :	
			print 'warn'
			errorFlag = 1
			add_problem("cannotPingError")
		end	
	end
	num = num + 1
end	
if 	errorFlag == 1 :
	return 'warn'
end
print 'success'
return 'success'