Open desiredrive opened 4 days ago
Hello @desiredrive,
Can you please elaborate the issue clearly?
Thank you.
Hi, sure. I see that currently there are a variety of parsers of "show device-tracking database" like:
show device-tracking database interface show device-tracking database mac show device-trackng database vlan
But not a parser for "show device-tracking database address" which is probably the most used variation of the device-tracking database filters; it is the only way to filter by IP which is better than MAC filtering or VLAN scope.
Hello @desiredrive,
Ok, I got it now. So you want the support for this command "show device-tracking database address". Can you please share the raw output for this command so the support can be added?
Thank you.
Sure thing!
Output when an entry is present/catched:
Edge-1#show device-tracking database address 172.19.10.12
Codes: L - Local, S - Static, ND - Neighbor Discovery, ARP - Address Resolution Protocol, DH4 - IPv4 DHCP, DH6 - IPv6 DHCP, PKT - Other Packet, API - API created
Preflevel flags (prlvl):
0001:MAC and LLA match 0002:Orig trunk 0004:Orig access
0008:Orig trusted trunk 0010:Orig trusted access 0020:DHCP assigned
0040:Cga authenticated 0080:Cert authenticated 0100:Statically assigned
Network Layer Address Link Layer Address Interface vlan prlvl age state Time left
ARP 172.19.10.12 d4e8.801f.4876 Te1/0/4 1021 0005 3mn REACHABLE 13 s try 0
Output when there is no entry:
Edge-1#show device-tracking database address 172.19.10.11
Codes: L - Local, S - Static, ND - Neighbor Discovery, ARP - Address Resolution Protocol, DH4 - IPv4 DHCP, DH6 - IPv6 DHCP, PKT - Other Packet, API - API created
Preflevel flags (prlvl):
0001:MAC and LLA match 0002:Orig trunk 0004:Orig access
0008:Orig trusted trunk 0010:Orig trusted access 0020:DHCP assigned
0040:Cga authenticated 0080:Cert authenticated 0100:Statically assigned
Network Layer Address Link Layer Address Interface vlan prlvl age state Time left
It is exremely similar to the other variants.
Thanks :)
Hello @desiredrive,
There is one issue here. If the network address is present in the output then we will see the parsed output like this:
{
"device": {
1: {
"dev_code": "ARP",
"network_layer_address": "172.19.10.12",
"link_layer_address": "d4e8.801f.4876",
"interface": "Te1/0/4",
"vlan_id": 1021,
"pref_level_code": 5,
"age": "3mn",
"state": "REACHABLE",
"time_left": "13 s try 0"
}
}
}
But when there is not entry for the network address, then we will get the SchemaEmptyParserError
exception. Because genieparser expects something in the return but in this case as there is no entry we get empty parsed output thus resulting in the exception.
So, you will have to handle it in the code somewhat like this when there is no entry in the output:
network_address = "172.19.10.12"
try:
output = dev.parse(f"show device-tracking database address {network_address}")
except SchemaEmptyParserError as e:
print(f"No entry found for {network_address}")
else:
print(f"{output = }")
Kindly check and let me know what you think.
Thank you.
That is perfect, the exception is clear enough. I like it!
Thanks
Currently, there is a schema for IPDT interface, vlan and mac. Most of the times, end customers are more aware of the IP address of the hosts for automation purposes rather than the rest of values; a schema for a single IP would be ideal for troubleshooting flows.
This can be of course workarounded by getting the entire IPDT DB with "show device-tracking database" and then selecting the IP from the schema, but it can be a problem when working with huge IPDT tables (slow response/heavy on memory).