{
    "name"  : "一对多镜像环回口版本缺陷",
    "problems" : {
        "flowError1" : {
            "desc"      : "【风险】S6220设备当前软件版本一对多镜像场景无法镜像RX方向的路由报文。",
            "advice"    : "【建议】升级最新S6220软件版本。"
        },
		 "flowError2" : {
            "desc"      : "【风险】S12000设备当前软件版本一对多镜像场景无法镜像RX方向的路由报文。",
            "advice"    : "【建议】升级S12000设备10.4(3b17)p5T6,Release(186189)或以上版本"
        }
    }
}
---------------------------code-------------------------------
ID= precondition('dailPort')
res2 = cli("show version")
resArr2 = res2.match(/10\.\d+/)
if resArr2 != null :
	return 'success'
end
step = false
if res2.indexOf("S12010") != -1 || res2.indexOf("S12006") != -1 :
	res = res2.split(/\r?\n/)
	i = 0
	while i < res.length:
		resTmp = res[i]
		if resTmp.indexOf("Software version") != -1 && resTmp.indexOf("Release") != -1:
			tmp = resTmp.match(/Release\(\d+\)/)
			tmp = tmp[0]
			num = tmp.match(/\d+/)
			num = num[0]
			print num
			if num > 183033:
				step = true
			end
			break
		end
		i = i + 1
	end
end

if res2.indexOf("S6220-24XS") != -1 || res2.indexOf("S6220-48XS4QXS") != -1 || res2.indexOf("S6220-48XT4QXS") != -1 :
	res = res2.split(/\r?\n/)
	i = 0
	while i < res.length:
		resTmp = res[i]
		if resTmp.indexOf("Software version") != -1 && resTmp.indexOf("Release") != -1:
			tmp = resTmp.match(/Release\(\d+\)/)
			tmp = tmp[0]
			num = tmp.match(/\d+/)
			num = num[0]
			print num
			if num > 173619:
				step = true
			end
			break
		end
		i = i + 1
	end
end
port = []
if step == true:
	step = false
	cmd = "show monitor session " + ID
	res = cli(cmd)
	if res.match(/remote vlan\s+\d+/) != null :
		step = true
		print res
		res = res.match(/remote vlan\s+\d+/)
		print res
		tmp = res[0]
		port = tmp.match(/\d+/)
		print port
	end
end
resY = []
if step == true:
	cmd = "show vlan id " + port
	res = cli(cmd)
	res = res.split(/\r?\n/)
	resY = res[3]
	resY = resY.match(/\w+\d+\/\d+\/\d+/ig)
	print resY
end

i = 0
while i < resY.length:
	cmd = "show run interface " + resY[i]
	res = cli(cmd)
	if res.indexOf("S6220") != -1 && res.indexOf("mac-loopback") != -1 :
		add_problem("flowError1")
		return 'warn'
	else if res.indexOf("S12000") != -1 && res.indexOf("mac-loopback") != -1 :
		resTmp = cli("show version slots")
		if resTmp.indexOf("mac-loopback") != -1 && resTmp.indexOf("DA") != -1 :
			add_problem("flowError2")
			return 'warn'
		end
	end
	i = i + 1
end
return 'success'