CiscoTestAutomation / genieparser

sub-component of Genie that parse the device output into structured datastructure
Apache License 2.0
248 stars 384 forks source link

'show ip eigrp topology' parser in ios-xe is not correctly parsing when there are multiple successors. #634

Open abinmathewabraham opened 2 years ago

abinmathewabraham commented 2 years ago

Let the output for the 'show ip eigrp topology' be:

R1#show ip eigrp topology
EIGRP-IPv4 Topology Table for AS(65535)/ID(1.1.1.1)
Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
       r - reply Status, s - sia Status

P 192.168.3.0/24, 4 successors, FD is 2195456
        via 10.1.1.2 (2195456/2169856), Ethernet0/0
        via 10.1.1.3 (2195456/2169856), Ethernet0/0
        via 10.2.2.2 (2195456/2169856), Ethernet1/0
        via 10.2.2.3 (2195456/2169856), Ethernet1/0
        via 192.168.2.2 (2681856/2169856), Serial2/1
        via 192.168.1.2 (2681856/2169856), Serial2/0
P 192.168.2.0/24, 1 successors, FD is 2169856
        via Connected, Serial2/1
P 10.2.2.0/24, 1 successors, FD is 281600
        via Connected, Ethernet1/0
P 192.168.1.0/24, 1 successors, FD is 2169856
        via Connected, Serial2/0
P 10.1.1.0/24, 1 successors, FD is 281600
        via Connected, Ethernet0/0

R1#

While using R1.parse("show ip eigrp topology") we get:

{
    "eigrp_instance": {
        "65535": {
            "vrf": {
                "default": {
                    "address_family": {
                        "IPv4": {
                            "eigrp_id": {
                                "1.1.1.1": {
                                    "eigrp_routes": {
                                        "10.1.1.0/24": {
                                            "FD": 281600,
                                            "known_via": "Connected",
                                            "outgoing_interface": "Ethernet0/0",
                                            "route": "10.1.1.0/24",
                                            "route_code": "P",
                                            "route_type": "Passive",
                                            "successor_count": 1,
                                        },
                                        "10.2.2.0/24": {
                                            "FD": 281600,
                                            "known_via": "Connected",
                                            "outgoing_interface": "Ethernet1/0",
                                            "route": "10.2.2.0/24",
                                            "route_code": "P",
                                            "route_type": "Passive",
                                            "successor_count": 1,
                                        },
                                        "192.168.1.0/24": {
                                            "FD": 2169856,
                                            "known_via": "Connected",
                                            "outgoing_interface": "Serial2/0",
                                            "route": "192.168.1.0/24",
                                            "route_code": "P",
                                            "route_type": "Passive",
                                            "successor_count": 1,
                                        },
                                        "192.168.2.0/24": {
                                            "FD": 2169856,
                                            "known_via": "Connected",
                                            "outgoing_interface": "Serial2/1",
                                            "route": "192.168.2.0/24",
                                            "route_code": "P",
                                            "route_type": "Passive",
                                            "successor_count": 1,
                                        },
                                        "192.168.3.0/24": {
                                            "FD": 2195456,
                                            "known_via": "192.168.1.2",
                                            "outgoing_interface": "Serial2/0",
                                            "route": "192.168.3.0/24",
                                            "route_code": "P",
                                            "route_type": "Passive",
                                            "successor_count": 4,
                                        },
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Observe the entry for 192.168.3.0/24. It has four successors. If there are multiple successors, then we need to have multiple entries under 192.168.3.0/24. In this case, we need to have 4 successor entries and 2 non successor entries. The first 4 will be the successor entries and the last 2 will be non successors.

abinmathewabraham commented 2 years ago

I feel we need to change the schema for this.

eigrp_routes
|------- 192.168.3.0/24
              |
              known_via
                   |  
                   |------- 10.1.1.2
                   |             |------- via - Ethernet0/0 (optional)
                   |             |------- is_successor - True
                   |             |------- rd - 2169856 (optional)
                   |             |------- cd - 2195456 (optional)
                   |
                   |------- 10.1.1.3
                   |             |------- via - Ethernet0/0 (optional)
                   |             |------- is_successor - True
                   |             |------- rd - 2169856 (optional)
                   |             |------- cd - 2195456 (optional)
                   |
                   |------- 10.2.2.2
                   |             |------- via - Ethernet1/0 (optional)
                   |             |------- is_successor - True
                   |             |------- rd - 2169856 (optional)
                   |             |------- cd - 2195456 (optional)
                   |
                   |------- 10.2.2.3
                   |             |------- via - Ethernet1/0 (optional)
                   |             |------- is_successor - True
                   |             |------- rd - 2169856 (optional)
                   |             |------- cd - 2195456 (optional)
                   |
                   |------- 192.168.2.2
                   |             |------- via - Serial2/1 (optional)
                   |             |------- is_successor - False
                   |             |------- rd - 2169856 (optional)
                   |             |------- cd - 2681856 (optional)
                   |
                   |------- 192.168.1.2
                                 |------- via - Serial2/0 (optional)
                                 |------- is_successor - False
                                 |------- rd - 2169856 (optional)
                                 |------- cd - 2681856 (optional)

You can find me in cisco directory too.

tahigash commented 2 years ago

@abinmathewabraham Genie Parser is open source. so can you consider contributing the fix/update?

reference: https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html

abinmathewabraham commented 2 years ago

@abinmathewabraham Genie Parser is open source. so can you consider contributing the fix/update?

reference: https://pubhub.devnetcloud.com/media/pyats-development-guide/docs/writeparser/writeparser.html

Thanks. I will take a look.