{
    "name"  : "正在是否有MPLS_TRUNK限制",
    "problems" : {
        "noResponse" : {
            "desc"      : "【风险】SVI配置label-switching且该SVI所属的物理口为trunk模式会导致该物理口关联的所有VLAN失去二层转发功能。",
            "advice"    : "【建议】请确认该接口是否用于二层转发，若需要请变更端口业务部署" 
        }
    }
}

---------------------------code------------------------------- 
res = cli("show version")
if res.indexOf("10.") != -1:
	return 'success'
end

res = cli("show run | begin interface VLAN")
resTmp = res.split("!")
i = 0
id = []
port = []
while i < (resTmp.length - 1):
	tmp = resTmp[i]
	if tmp.indexOf("interface VLAN") != -1 && tmp.indexOf("label-switching") != -1:
		idArr = tmp.match(/interface VLAN\s\d+/)
		id1 = idArr[0]
		print id1
		id1 = id1.match(/\d+/)
		id1 = id1[0]
		print id1
		id.push(id1)
	end
	i = i + 1
end

if id.length > 0:
	i = 0
	while i < id.length:
		cmd = "show vlan id " + id[i]
		res = cli(cmd)
		res = res.split(/\r?\n/ig)
		j = 2
		while j < (res.length - 1):
			resTmp = res[j]
			resTmp = resTmp.split(/\s+/)
			resTmp = resTmp[3]
			resTmp = resTmp.split(",")
			port = port.concat(resTmp)
			j = j + 1
		end
		i = i + 1
	end
end

i = 0
while i < port.length:
	cmd = "show run interface " + port[i]
	res = cli(cmd)
	if res.indexOf("switchport mode trunk") != -1:
		add_problem("noResponse")
		return 'warn'
	end
	i = i + 1
end

return 'success'