Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOS-XR] show vrf all detail parser - Interfaces list not captured #910

Open
Kani999 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #911
Open

[IOS-XR] show vrf all detail parser - Interfaces list not captured #910

Kani999 opened this issue Nov 7, 2024 · 1 comment · May be fixed by #911
Assignees

Comments

@Kani999
Copy link
Contributor

Kani999 commented Nov 7, 2024

Description

While using the Genieparser for the show vrf all detail command on an IOS XR device, we've encountered an issue where the parser fails to capture the list of interfaces assigned to a VRF. As a result, the interfaces field in the parsed JSON output is empty, even though interfaces are present in the actual command output.

Example

  • Raw data: As shown above, the Interfaces section includes FortyGigE0/0/0/2/0.444444
VRF VRF_NAME; RD 10.10.10.10:10; VPN ID not set
VRF mode: Regular
Description not set
Interfaces:
  FortyGigE0/0/0/2/0.444444
Address family IPV4 Unicast
  Import VPN route-target communities:
    RT:2222:3333
  Export VPN route-target communities:
    RT:2222:3333
  No import route policy
  No export route policy
Address family IPV6 Unicast
  No import VPN route-target communities
  No export VPN route-target communities
  No import route policy
  No export route policy
  • Parsed data: interfaces = []
{
    "VRF_NAME": {
        "address_family": {
            "ipv4 unicast": {
                "route_target": {
                    "2222:3333": {
                        "route_target": "2222:3333",
                        "rt_type": "both"
                    }
                }
            },
            "ipv6 unicast": {}
        },
        "description": "not set",
        "interfaces": [],
        "route_distinguisher": "10.10.10.10:10",
        "vrf_mode": "regular"
    }
}

Expected Behavior:

The parser should correctly parse and include the list of interfaces assigned to the VRF in the output. In this case, the interfaces field should contain at least one interface, FortyGigE0/0/0/2/0.444444.

Reproduce problem:

from genie.libs.parser.iosxr.show_vrf import ShowVrfAllDetail
from pprint import pprint


input_data = """
VRF VRF_NAME; RD 10.10.10.10:10; VPN ID not set
VRF mode: Regular
Description not set
Interfaces:
  FortyGigE0/0/0/2/0.444444
Address family IPV4 Unicast
  Import VPN route-target communities:
    RT:2222:3333
  Export VPN route-target communities:
    RT:2222:3333
  No import route policy
  No export route policy
Address family IPV6 Unicast
  No import VPN route-target communities
  No export VPN route-target communities
  No import route policy
  No export route policy
"""

result = ShowVrfAllDetail.cli(self = None, output=input_data)
pprint(result)
@Kani999
Copy link
Contributor Author

Kani999 commented Nov 7, 2024

class ShowVrfAllDetail(ShowVrfAllDetailSchema):
    """Parser for show vrf all detail"""

    cli_command = ['show vrf {vrf} detail', 'show vrf all detail']

    def cli(self, vrf='', output=None):
        if output is None:
            if vrf:
                cmd = self.cli_command[0].format(vrf=vrf)
            else:
                cmd = self.cli_command[1]
            out = self.device.execute(cmd)
        else:
            out = output
        
        # Init vars
        vrf_dict = {}
        af_dict = {}
        rt_type = None

        for line in out.splitlines():
            line = line.replace('\t', '    ')
            line = line.strip()

.
.
.
.

            # Interfaces:
            #     GigabitEthernet0/0/0/1
            p4 = re.compile(r'^Interfaces:$')
            m = p4.match(line)
            if m:
                vrf_dict[vrf]['interfaces'] = []
                continue
            #   GigabitEthernet0/0/0/0.390
            #   Bundle-Ether15.514
            p4_1 = re.compile(r'^(?P<intf>([G|g]i.*|[B|b]un.*|'
                              r'[T|t]en.*|[P|p]o.*|[V|v]lan.*|'
                              r'[L|l]o.*))$')

            m = p4_1.match(line)
            if m:
                intf = m.groupdict()['intf']
                vrf_dict[vrf]['interfaces'].append(intf)
                continue
.
.
.
.

Problem is, the regex p4_1 does not recognize all types of interfaces such as FortyGigE, and others.

            p4_1 = re.compile(r'^(?P<intf>([G|g]i.*|[B|b]un.*|'
                              r'[T|t]en.*|[P|p]o.*|[V|v]lan.*|'
                              r'[L|l]o.*))$')

@SohanTirpude SohanTirpude self-assigned this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants