{
    "name"  : "IPSec总部配置检查",
    "problems" : {
        "NoUseMap" : {
            "desc"      : "【问题】接口下未应用map",
            "advice"    : "【建议】在接口下应用map"
        },
		"NoMapDynamic" : {
            "desc"      : "【问题】map的类型不是dynamic",
            "advice"    : "【建议】总部建议配置为动态map"
        },
		"NoTransformSet" : {
            "desc"      : "【问题】没有配置转换集",
            "advice"    : "【建议】需要配置转换集"
        },
		"NoSetKey" : {
            "desc"      : "【问题】需要配置对端的共享密钥",
            "advice"    : "【建议】配置对端的共享密钥"
        }
    }
}
---------------------------code-------------------------------
ipsecHeadquarters = precondition('ipsecHeadquarters')
port = precondition('keyChangeBand')
if ipsecHeadquarters == "":
    return 'skip'
end

print 'port='+port
cmd = 'show run int ' + port
result=cli(cmd)
print result
cryFlag = result.match(/crypto map/ig)
if cryFlag == null:
    add_problem('NoUseMap')
    return 'warn'
end

cmd = 'show run int ' + port
res = cli(cmd)
resArr = res.split(/\r?\n/) 
mapType = []
j = 1
while j < (resArr.length - 1):
  resArrTmp = resArr[j]
  resArrTmp = resArrTmp.trim()
  if resArrTmp.indexOf("crypto map")!=-1 :
	 mapType.push(resArrTmp)
  end
  j = j + 1
end 
cmd2 = 'show run | inc ' + mapType[0]
print cmd2
res2 = cli(cmd2)
print res2
if res2.indexOf("dynamic")==-1 :
    add_problem('NoMapDynamic')
	return 'warn'
end

res3 = cli("show run")
print 'res3='+res3
if res3.indexOf("crypto ipsec transform-set ipsecSet")==-1 :
    add_problem('NoTransformSet')
	return 'warn'
end


res4 = cli("show run | inc crypto isakmp key")
print 'res4='+res4
if res4.indexOf("crypto isakmp key")==-1 :
  add_problem('NoSetKey')
  return 'warn'
end
return 'success'

