
{
    "name"  : "SVI接口开启VRRP及绑定ACL时限制仅三层生效",
    "problems" : {
        "svi_vrrp" : {
            "desc"      : "【问题】接口${0}开启VRRP及绑定ACL时未配置svi router-acls enable会导致部分报文转发不通。",
            "advice"    : "【建议】全局下配置该功能，点击自动修复自动下发该命令"
        }
    }
}

---------------------------code-------------------------------
result = 'pass'
restore_cmd = []
reback_cmd = []
log_vrrp = cli('show vrrp brief')
log_vrrpList = log_vrrp.split("\r\n")
reg = /VLAN\s+(\d+)\s+\d+\s+\d+/
port = ""
if !isAclEnable() :
	foreach data in log_vrrpList:
		r = data.match(reg)
		if r != null:
			intf = r[1]
			intf_cmd = format('show run interface vlan %s',intf)
			log_intf = cli(intf_cmd)
			print(log_intf)
			if log_intf.indexOf('ip access-group') > -1:
				port = port + 'VLAN'+intf+ "、"
				result = 'fail'
			end
		end
	end
end

if result == 'fail':
	change_title('检测到接口开启VRRP及绑定ACL情况下未配置svi router-acls enable')
	
	restore_cmd.push('config')
	restore_cmd.push('svi router-acls enable')
	restore_cmd.push('end')
	restore_cmd.push('write')
	
	reback_cmd.push('config')
	reback_cmd.push('no svi router-acls enable')
	reback_cmd.push('end')
	reback_cmd.push('write')
	add_problem('svi_vrrp',[port],restore_cmd,reback_cmd)
	return 'warn'
end

return 'success'

def isAclEnable():
	result = 1
	log_acl = cli('show run | include svi router-acls enable')
	if log_acl.indexOf('svi router-acls enable')> -1:
		result = 0
	end
	return result
end
