Hello everyone,
The rules I wrote are
rule "Test 1 Rule"
salience 1000
when
Line ( $admin : line)
eval ( $admin.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
Line ( $lineSecond : line)
eval (
$lineSecond.matches("^\\s*(\\S+)\\s+is\\s+(up|down|administratively
down),\\s*line\\s+protocol\\s+is\\s+(up|down)\\s*$"))
device : Device()
then
System.out.println("********************************************");
device.setVendorType("Foundry");
end
rule "Juniper Show Interface CanIParse() Rule"
salience 5000
when
Line ( $regex : line)
eval ( $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
Line ( $lineStr : line)
eval (
$lineStr.matches("^.*\\s*Physical\\s+interface:\\s*([^,\\s]+),\\s+([^,]+),.*$"))
device : Device()
then
System.out.println
("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
device.setVendorType("Juniper");
end
Basically the rules are searching for two regular expressions, of which one
is same for the both of the rules.But when i write the rules like the above
I do not get the correct o/p, but however if i change my rules to (bold) as
below, I get the correct output.So is it necessary the the declaration has
to be same if the both the rules have same regex
rule "Test 1 Rule"
salience 1000
when
Line ( $regex : line)
eval ( $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
Line ( $lineSecond : line)
eval (
$lineSecond.matches("^\\s*(\\S+)\\s+is\\s+(up|down|administratively
down),\\s*line\\s+protocol\\s+is\\s+(up|down)\\s*$"))
device : Device()
then
System.out.println("********************************************");
device.setVendorType("Foundry");
end
rule "Juniper Show Interface CanIParse() Rule"
salience 5000
when
Line ( $regex : line)
eval ( $regex.matches("^.*@\\S*[#>]\\s*show\\s+interface[s]*\\s*$"))
Line ( $lineStr : line)
eval (
$lineStr.matches("^.*\\s*Physical\\s+interface:\\s*([^,\\s]+),\\s+([^,]+),.*$"))
device : Device()
then
System.out.println
("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
device.setVendorType("Juniper");
end
Thanks
Shiva