CiscoTestAutomation / genieparser

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

Issue with show mpls traffic-eng tunnels in iosxe #870

Closed fjuesas closed 1 month ago

fjuesas commented 1 month ago

Hi all,

When trying to parse a show mpls traffic-eng tunnels:

genie parse ‘show mpls traffic-eng tunnel’ --testbed-file testbed.yaml --device BADA

On a device with IOS XE (ASR-907), I get the following error:

_Traceback (most recent call last): File ‘src/genie/cli/commands/parser.py’, line 339, in genie.cli.commands.parser.ParserCommand.parse File ‘src/genie/conf/base/device.py’, line 535, in genie.conf.base.device.Device.parse File ‘src/genie/conf/conf/base/device.py’, line 574, in genie.conf.base.device.Device._get_parser_output File ‘src/genie/conf/conf/base/device.py’, line 572, in genie.conf.base.device.Device._get_parser_output File ‘src/genie/genie/metaparser/_metaparser.py’, line 308, in genie.metaparser._metaparser.MetaParser.parse File ‘/volume1/pyats/lib/python3.8/site-packages/genie/libs/parser/iosxe/show_mpls.py’, line 3899, in cli res[‘tunnel_type’][base_key][‘tunnelname’][key][ UnboundLocalError: local variable ‘key’ referenced before assignment

Can anyone help me?

Many thanks,

Harishv01 commented 1 month ago

Hi,kindly give me some time to reproduce and fix the issue. Thank you.

fjuesas commented 1 month ago

Hi,kindly give me some time to reproduce and fix the issue. Thank you.

Thank you for your time Harishv01. Let me know if you need anything else.

Harishv01 commented 1 month ago

Hi, I am not seeing the issue I got the output. Can you please let me know which version of pyats you are using?

Output: {'tunnel_type': {'p2p_tunnels': {'tunnel_name': {'Tunnel100': {'destination': '2.2.2.2', 'status': {'admin': 'up', 'oper': 'up', 'path': 'valid', 'signalling': 'connected', 'path_option': {'1': {'type': 'dynamic', 'path_weight': 1}}}, 'config_parameters': {'bandwidth': 500, 'bandwidth_unit': 'kbps', 'bandwidth_type': 'Global', 'priority': {'setup_priority': 7, 'hold_priority': 7}, 'affinity': '0x0/0xFFFF', 'metric_used': 'TE', 'metric_type': 'default', 'path_selection_tiebreaker': {'global': 'not set', 'tunnel_specific': 'not set', 'effective': 'min-fill', 'effective_type': 'default'}, 'hop_limit': 'disabled', 'cost_limit': 'disabled', 'path_invalidation_timeout': 10000, 'path_invalidation_timeout_unit': 'msec', 'path_invalidation_timeout_type': 'default', 'action': 'Tear', 'autoroute': 'enabled', 'lockdown': 'disabled', 'loadshare': 500, 'max_load_share': 4000000, 'load_share_type': 'bw-based', 'auto_bw': 'disabled', 'fault_oam': 'disabled', 'wrap_protection': 'disabled', 'wrap_capable': 'No'}, 'active_path_option_parameters': {'state': {'active_path': '1', 'path_type': 'dynamic'}, 'bandwidthoverride': 'disabled', 'lockdown': 'disabled', 'verbatim': 'disabled'}, 'node_hop_count': 1, 'inlabel': ['-'], 'outlabel': ['Port-channel20', 'implicit-null'], 'next_hop': ['192.1.1.2'], 'rsvp_signalling_info': {'src': '3.3.3.3', 'dst': '2.2.2.2', 'tun_id': 100, 'tun_instance': 301, 'rsvp_path_info': {'my_address': '192.1.1.1', 'explicit_route': ['192.1.1.2', '2.2.2.2'], 'record_route': 'NONE', 'tspec': {'ave_rate': 500, 'ave_rate_unit': 'kbits', 'burst': 1000, 'burst_unit': 'bytes', 'peak_rate': 500, 'peak_rate_unit': 'kbits'}}, 'rsvp_resv_info': {'record_route': 'NONE', 'fspec': {'ave_rate': 500, 'ave_rate_unit': 'kbits', 'burst': 1000, 'burst_unit': 'bytes', 'peak_rate': 500, 'peak_rate_unit': 'kbits'}}}, 'history': {'tunnel': {'time_since_created': '21 hours, 59 minutes', 'time_since_path_change': '17 hours, 13 minutes', 'number_of_lsp_ids_used': 301}, 'current_lsp_id': {'301': {'uptime': '17 hours, 13 minutes', 'selection': 'reoptimization'}}, 'prior_lsp_id': {'300': {'id': 'path option unknown', 'removal_trigger': 'configuration changed '}}}}, 'Tunnel101': {'destination': '2.2.2.2', 'status': {'admin': 'admin-down', 'oper': 'down', 'path': 'not valid', 'signalling': 'down', 'path_option': {'1': {'type': 'explicit', 'path_name': 'R3_R5_R2'}}}, 'config_parameters': {'bandwidth': 5000, 'bandwidth_unit': 'kbps', 'bandwidth_type': 'Global', 'priority': {'setup_priority': 7, 'hold_priority': 7}, 'affinity': '0x0/0xFFFF', 'metric_used': 'TE', 'metric_type': 'default', 'path_selection_tiebreaker': {'global': 'not set', 'tunnel_specific': 'not set', 'effective': 'min-fill', 'effective_type': 'default'}, 'hop_limit': 'disabled', 'cost_limit': 'disabled', 'path_invalidation_timeout': 10000, 'path_invalidation_timeout_unit': 'msec', 'path_invalidation_timeout_type': 'default', 'action': 'Tear', 'autoroute': 'enabled', 'lockdown': 'disabled', 'loadshare': 5000, 'max_load_share': 0, 'load_share_type': 'bw-based', 'auto_bw': 'disabled', 'fault_oam': 'disabled', 'wrap_protection': 'disabled', 'wrap_capable': 'No'}, 'history': {'tunnel': {'time_since_created': '20 minutes, 3 seconds', 'time_since_path_change': '1 minutes, 27 seconds', 'number_of_lsp_ids_used': 11}, 'prior_lsp_id': {'11': {'id': 'path option unknown', 'removal_trigger': 'tunnel shutdown'}}}}, 'Tunnel102': {'destination': '2.2.2.2', 'status': {'admin': 'up', 'oper': 'up', 'path': 'valid', 'signalling': 'connected', 'path_option': {'1': {'type': 'explicit', 'path_name': 'R3_R5_R2', 'path_weight': 2}, '2': {'type': 'dynamic'}}}, 'config_parameters': {'bandwidth': 5000, 'bandwidth_unit': 'kbps', 'bandwidth_type': 'Global', 'priority': {'setup_priority': 7, 'hold_priority': 7}, 'affinity': '0x0/0xFFFF', 'metric_used': 'TE', 'metric_type': 'default', 'path_selection_tiebreaker': {'global': 'not set', 'tunnel_specific': 'not set', 'effective': 'min-fill', 'effective_type': 'default'}, 'hop_limit': 'disabled', 'cost_limit': 'disabled', 'path_invalidation_timeout': 10000, 'path_invalidation_timeout_unit': 'msec', 'path_invalidation_timeout_type': 'default', 'action': 'Tear', 'autoroute': 'enabled', 'lockdown': 'disabled', 'loadshare': 5000, 'max_load_share': 400000, 'load_share_type': 'bw-based', 'auto_bw': 'disabled', 'fault_oam': 'disabled', 'wrap_protection': 'disabled', 'wrap_capable': 'No'}, 'active_path_option_parameters': {'state': {'active_path': '1', 'path_type': 'explicit'}, 'bandwidthoverride': 'disabled', 'lockdown': 'disabled', 'verbatim': 'disabled'}, 'node_hop_count': 2, 'inlabel': ['-'], 'outlabel': ['Port-channel40', '19'], 'next_hop': ['194.1.1.2'], 'rsvp_signalling_info': {'src': '3.3.3.3', 'dst': '2.2.2.2', 'tun_id': 102, 'tun_instance': 1, 'rsvp_path_info': {'my_address': '194.1.1.1', 'explicit_route': ['194.1.1.2', '197.1.1.1', '197.1.1.2', '2.2.2.2'], 'record_route': 'NONE', 'tspec': {'ave_rate': 5000, 'ave_rate_unit': 'kbits', 'burst': 1000, 'burst_unit': 'bytes', 'peak_rate': 5000, 'peak_rate_unit': 'kbits'}}, 'rsvp_resv_info': {'record_route': 'NONE', 'fspec': {'ave_rate': 5000, 'ave_rate_unit': 'kbits', 'burst': 1000, 'burst_unit': 'bytes', 'peak_rate': 5000, 'peak_rate_unit': 'kbits'}}}, 'history': {'tunnel': {'time_since_created': '2 minutes, 21 seconds', 'time_since_path_change': '2 minutes, 10 seconds', 'number_of_lsp_ids_used': 1}, 'current_lsp_id': {'1': {'uptime': '2 minutes, 10 seconds'}}}}}}, 'p2mp_tunnels': {'tunnel_name': {}}, 'p2mp_sub_lsps': {'tunnel_name': {}}}}

fjuesas commented 1 month ago

Hi Harishv01,

pyats version check You are currently running pyATS version: 24.6 Python: 3.8.12 [64bit]

Package Version


genie 24.6 genie.libs.clean 24.6 genie.libs.conf 24.6 genie.libs.filetransferutils 24.6 genie.libs.health 24.6 genie.libs.ops 24.6 genie.libs.parser 24.6 genie.libs.robot 24.6 genie.libs.sdk 24.6 genie.telemetry 24.6 genie.trafficgen 24.6 pyats 24.6 pyats.aereport 24.6 pyats.aetest 24.6 pyats.async 24.6 pyats.connections 24.6 pyats.contrib 24.6 pyats.datastructures 24.6 pyats.easypy 24.6 pyats.kleenex 24.6 pyats.log 24.6 pyats.reporter 24.6 pyats.results 24.6 pyats.robot 24.6 pyats.tcl 24.6 pyats.topology 24.6 pyats.utils 24.6 rest.connector 24.6 unicon 24.6 unicon.plugins 24.6 yang.connector 24.6

The device have IOS XE Version 16.12.5 (Gibraltar). If I try to parse for a tunnel only, the error is:

genie parse "show mpls traffic-eng tunnels tunnel 12831" --testbed-file testbed.yaml --device BADA 0%| | 0/1 [00:00<?, ?it/s]

Issue with the parser show mpls traffic-eng tunnels tunnel 12831

Traceback (most recent call last): File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse File "src/genie/conf/base/device.py", line 535, in genie.conf.base.device.Device.parse File "src/genie/conf/base/device.py", line 574, in genie.conf.base.device.Device._get_parser_output File "src/genie/conf/base/device.py", line 572, in genie.conf.base.device.Device._get_parser_output File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse File "/volume1/pyats/lib/python3.8/site-packages/genie/libs/parser/iosxe/show_mpls.py", line 3320, in cli res['tunnel'][key][key1] = {} UnboundLocalError: local variable 'key' referenced before assignment

And the real output is:

show mpls traffic-eng tunnels tunnel 12831

Name: Entrega PEDR (Tunnel12831) Destination: 10.166.0.1 Status: Admin: up Oper: up Path: valid Signalling: connected path option 5, type explicit Path-BA-SM-PE-Pe (Basis for Setup, path weight 21) path option 10, type dynamic

Config Parameters: Bandwidth: 0 kbps (Global) Priority: 1 1 Affinity: 0x0/0xFFFF Metric Type: TE (default) Path-selection Tiebreaker: Global: not set Tunnel Specific: not set Effective: min-fill (default) Hop Limit: disabled [ignore: Explicit Path Option with all Strict Hops] Cost Limit: disabled Path-invalidation timeout: 10000 msec (default), Action: Tear AutoRoute: enabled LockDown: disabled Loadshare: 0 [0] bw-based auto-bw: disabled Fast Reroute: enabled, Node Protection: No, Bandwidth Protection: No Fault-OAM: disabled, Wrap-Protection: disabled, Wrap-Capable: No Active Path Option Parameters: State: explicit path option 5 is active BandwidthOverride: disabled LockDown: disabled Verbatim: disabled Node Hop Count: 3

InLabel : - OutLabel : TenGigabitEthernet0/5/8, 10282 Next Hop : 10.166.17.121 FRR OutLabel : Tunnel52829, 10282 RSVP Signalling Info: Src 10.166.0.11, Dst 10.166.0.1, Tun_Id 12831, Tun_Instance 54 RSVP Path Info: My Address: 10.166.17.122
Explicit Route: 10.166.17.121 10.166.16.37 10.166.16.46 10.166.0.1 Record Route: NONE Tspec: ave rate=0 kbits, burst=1000 bytes, peak rate=0 kbits RSVP Resv Info: Record Route: 10.166.0.8(10282) 10.166.0.200(16424) 10.166.16.37(16424) 10.166.0.1(0) Fspec: ave rate=0 kbits, burst=0 bytes, peak rate=0 kbits Shortest Unconstrained Path Info: Path Weight: 21 (TE) Explicit Route: 10.166.17.30 10.166.16.85 10.166.16.46 10.166.0.1

History: Tunnel: Time since created: 49 days, 17 hours, 2 minutes Time since path change: 20 days, 17 minutes Number of LSP IDs (Tun_Instances) used: 54 Current LSP: [ID: 54] Uptime: 20 days, 17 minutes Selection: reoptimization Prior LSP: [ID: 53] ID: path option unknown

Thank you for your time!

Harishv01 commented 1 month ago

Hi, I am able to reproduce the issue and will fix it today. Thank you

fjuesas commented 1 month ago

Hi Harish, I hadn't read your message, sorry. Were you finally able to reproduce the problem? Were you able to solve it? I'm waiting, thanks for your time!

Harishv01 commented 1 month ago

I have raised the PR for this and the output is as follows:

expected_output ={ 
    "tunnel": {
        "Tunnel12831": {
            "destination": "10.166.0.1",
            "status": {
                "admin": "up",
                "oper": "up",
                "path": "valid",
                "signalling": "connected",
                "path_option": {
                    "5": {
                        "type": "explicit",
                        "path_name": "Path-BA-SM-PE-Pe",
                        "path_weight": 21
                    },
                    "10": {
                        "type": "dynamic"
                    }
                }
            },
            "config_parameters": {
                "bandwidth": 0,
                "bandwidth_unit": "kbps",
                "bandwidth_type": "Global",
                "priority": {
                    "setup_priority": 1,
                    "hold_priority": 1
                },
                "affinity": "0x0/0xFFFF",
                "metric_used": "TE",
                "metric_type": "default",
                "path_selection_tiebreaker": {
                    "global": "not set",
                    "tunnel_specific": "not set",
                    "effective": "min-fill",
                    "effective_type": "default"
                },
                "hop_limit": "disabled",
                "cost_limit": "disabled",
                "path_invalidation_timeout": 10000,
                "path_invalidation_timeout_unit": "msec",
                "path_invalidation_timeout_type": "default",
                "action": "Tear",
                "autoroute": "enabled",
                "lockdown": "disabled",
                "loadshare": 0,
                "max_load_share": 0,
                "load_share_type": "bw-based",
                "auto_bw": "disabled",
                "fault_oam": "disabled",
                "wrap_protection": "disabled",
                "wrap_capable": "No"
            },
            "active_path_option_parameters": {
                "state": {
                    "active_path": "5",
                    "path_type": "explicit"
                },
                "bandwidthoverride": "disabled",
                "lockdown": "disabled",
                "verbatim": "disabled"
            },
            "node_hop_count": 3,
            "inlabel": [
                "-"
            ],
            "next_hop": [
                "10.166.17.121"
            ],
            "frr_outlabel": [
                "Tunnel52829",
                " 10282"
            ],
            "rsvp_signalling_info": {
                "src": "10.166.0.11",
                "dst": "10.166.0.1",
                "tun_id": 12831,
                "tun_instance": 54,
                "rsvp_path_info": {
                    "my_address": "10.166.17.122",
                    "explicit_route": [
                        "10.166.17.121",
                        "10.166.16.37",
                        "10.166.16.46",
                        "10.166.0.1",
                        "10.166.16.37(16424)",
                        "10.166.0.1(0)"
                    ],
                    "record_route": "NONE",
                    "tspec": {
                        "ave_rate": 0,
                        "ave_rate_unit": "kbits",
                        "burst": 1000,
                        "burst_unit": "bytes",
                        "peak_rate": 0,
                        "peak_rate_unit": "kbits"
                    }
                },
                "rsvp_resv_info": {
                    "record_route": "10.166.0.8(10282) 10.166.0.200(16424)",
                    "fspec": {
                        "ave_rate": 0,
                        "ave_rate_unit": "kbits",
                        "burst": 0,
                        "burst_unit": "bytes",
                        "peak_rate": 0,
                        "peak_rate_unit": "kbits"
                    }
                }
            },
            "shortest_unconstrained_path_info": {
                "path_weight": "21",
                "path_weight_type": "TE",
                "explicit_route": [
                    "10.166.17.30",
                    "10.166.16.85",
                    "10.166.16.46",
                    "10.166.0.1"
                ]
            },
            "history": {
                "tunnel": {
                    "time_since_created": "49 days, 17 hours, 2 minutes",
                    "time_since_path_change": "20 days, 17 minutes",
                    "number_of_lsp_ids_used": 54
                },
                "current_lsp_id": {
                    "54": {
                        "uptime": "20 days, 17 minutes",
                        "selection": "reoptimization"
                    }
                },
                "prior_lsp_id": {
                    "53": {
                        "id": "path option unknown"
                    }
                }
            }
        }
    }
}
Harishv01 commented 1 month ago

I will let you know once it is merged. Thank you.

Harishv01 commented 1 month ago

We have merged the PR and the fix will be available in the next version, i.e., 24.7. Hence, I am closing the ticket. Thank you.