{
    "name"  : "用户登录后_无法访问隧道资源",
    "problems" : {
        "nextHopError1" : {
            "desc"      : "【问题】红色预警：SSLVPN服务未开启或开启失败",
            "advice"    : "【建议】请开启SSLVPN服务或参照SSLVPN服务无法启动。"
        },
		"nextHopError2" : {
            "desc"      : "【问题】无",
            "advice"    : "【建议】该用户无安全隧道资源，请为用户分配安全隧道资源。"
        },
		"nextHopError3" : {
            "desc"      : "【问题】无",
            "advice"    : "【建议】将无法访问的服务器IP地址添加到安全隧道资源，并授权给用户"
        },
		"nextHopError4" : {
            "desc"      : "【问题】安全隧道接入未成功启动",
            "advice"    : "【建议】请用桌面客户端登录"
        },
		"nextHopError5" : {
            "desc"      : "【问题】无",
            "advice"    : "【建议】未收到内网服务器的回应，请确认回指路由、内部网络配置是否正确"
        },
		"nextHopError6" : {
            "desc"      : "【问题】无",
            "advice"    : "【建议】回应报文命中xxx接口(应该要是SSLVPN 0),请确认选路策略是否正确。"
        }
    }
}
---------------------------code-------------------------------
serverIp = precondition('serverIp')
tunnelIp = precondition('tunnelIp')
userName = precondition('userName')
publicIp = precondition('publicIp')
print publicIp
res = cli("show sslvpn gateway")
if res.match("IP tunnel service: on") == null:
	add_problem("nextHopError1")
    return "warn"
end

cmd = "show sslvpn resource-group by-user-name " + userName
res = cli(cmd)
resTmp = res.split(/\r?\n/)
if resTmp.length < 2:
	add_problem("nextHopError2")
    return "warn"
end

res = cli("show sslvpn resource-group by-name")
if res.indexOf("Iptunnel Enable: TRUE") == -1:
	add_problem("nextHopError3")
    return "warn"
end

cmd = "show sslvpn resource-group detail-by-user-name " + userName
res = cli(cmd)
print res
res = res.split(/\r?\n/)
i = 0
endnum = ""
while i < (res.length - 1):
	resTmp = res[i]
	if resTmp.indexOf("host[net]") != -1:
		Tmp = resTmp.split(":")
		Tmp = Tmp[1]
		Tmp = Tmp.trim()
		resTmper = Tmp.split("/")
		endnum = resTmper[1]
	end
	i = i + 1
end

serverIp = serverIp[0]
Ip = serverIp.split(".")
result = isBetweenIPSection(Ip, endnum)
if result == false :
	add_problem("nextHopError3")
	return "warn"
end

cmd = "show sslvpn session username " + userName
res = cli(cmd)

if res.indexOf("Session status: running-syned") == -1 || res.indexOf("Iptunnel access: off") != -1:
	add_problem("nextHopError4")
    return "warn"
end

cmd = "show ip fpm flows filter 0 " + tunnelIp + " 32 " + serverIp + " 32"
res = cli(cmd)
resTmp = res.split(/\r?\n/)
print resTmp
if resTmp.length < 5:
	return 'success'
else :
	j = 2
	while j < (resTmp.length - 1) :
		resTmp = resTmp[j]
		resTmper = resTmp.split(/\s+/)
		if resTmper[7] == 0 :
			add_problem("nextHopError5")
			return "warn"
		end
	end
end 

cmd = "show ip fpm private filter 1 0 " + tunnelIp + " 32 " + serverIp + " 32"
res = cli(cmd)

rest = cli("show ip ref adj")
if rest.indexOf("SSLVPN 0") == -1:
	add_problem("nextHopError6")
    return "warn"
end

return "success"

