ttp
ttp copied to clipboard
cidr_match and list problem
It seems that the cider_match is not checking all subnets in the list from the file but ONLY the last one:
<input load="text" name="test1-56">
interface Lo4
ip address 4.4.4.4 32
!
interface Lo3
ip address 3.3.3.3 32
!
interface Lo2
ip address 2.2.2.2 32
!
interface Lo1
ip address 1.1.1.30 32
</input>
<vars name="subnet_list" include="./vars.txt">
</vars>
<group name="test1_56_cidr_match_vars" input="test1-56" contains="ip">
interface {{ interface }}
ip address {{ ip | cidr_match(subnet_list) }} {{ mask }}
</group>
./vars.txt
subnet_list="1.1.1.0/24"
subnet_list="2.2.2.0/24"
Output:
[
[
{
"subnet_list": {
"subnet_list": "2.2.2.0/24"
},
"test1_56_cidr_match_vars": {
"interface": "Lo2",
"ip": "2.2.2.2",
"mask": "32"
}
}
]
]
Is there a way to read all subnets from the file and match it against the input? Again it seems that only the last subnet is tested against the input ;(
Not with current implementation of TTP cidr_match function, best what can do probably to use macro python function to check subnets overlap.