CiscoTestAutomation / genieparser

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

iosxe "show ipv6 interface brief" parse fails #730

Open platu opened 1 year ago

platu commented 1 year ago

Hi,

While editing a lab text, I encountered the following error:

(pyats) etu@vm$ genie parse "show ipv6 interface brief" --testbed-file yaml/testbed.yml --devices rtr001
Enter enable password for device rtr001: -
  0%|                                                                                                                               | 0/1 [00:00<?, ?it/s]Issue with the parser show ipv6 interface brief

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 531, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 570, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/conf/base/device.py", line 568, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 308, in genie.metaparser._metaparser.MetaParser.parse
  File "/home/etu/labs/Lab16/pyats/lib/python3.10/site-packages/genie/libs/parser/iosxe/show_interface.py", line 3058, in cli
    ret_dict[intf]['joined_group_addresses'] = sorted(joined_group)
UnboundLocalError: local variable 'intf' referenced before assignment
100%|█████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.09s/it]

The genie version in use is:

pip freeze | grep genie
genie==23.1
genie.libs.clean==23.1
genie.libs.conf==23.1
genie.libs.filetransferutils==23.1
genie.libs.health==23.1
genie.libs.ops==23.1
genie.libs.parser==23.1
genie.libs.robot==23.1.1
genie.libs.sdk==23.1
genie.telemetry==23.1
genie.trafficgen==23.1

The CSR1000v command output is:

rtr001#sh ipv6 interface brief
GigabitEthernet1       [up/up]
    FE80::FAAD:CAFF:FEFE:1
    2001:678:3FC:34:FAAD:CAFF:FEFE:1
GigabitEthernet2       [up/up]
    unassigned
GigabitEthernet2.100   [up/up]
    FE80::FAAD:CAFF:FEFE:C8
    2001:678:3FC:64::C8
GigabitEthernet2.101   [up/up]
    FE80::FAAD:CAFF:FEFE:C8
    2001:678:3FC:65::C8
GigabitEthernet2.102   [up/up]
    FE80::FAAD:CAFF:FEFE:C8
    2001:678:3FC:66::C8

Finally, the "show ip interface brief" parsing works fine on the same instance:

genie parse "show ip interface brief" --testbed-file yaml/testbed.yml --devices rtr001
Enter enable password for device rtr001: 
{
  "interface": {
    "GigabitEthernet1": {
      "interface_is_ok": "YES",
      "ip_address": "198.18.53.1",
      "method": "DHCP",
      "protocol": "up",
      "status": "up"
    },
    "GigabitEthernet2": {
      "interface_is_ok": "YES",
      "ip_address": "unassigned",
      "method": "NVRAM",
      "protocol": "up",
      "status": "up"
    },
    "GigabitEthernet2.100": {
      "interface_is_ok": "YES",
      "ip_address": "unassigned",
      "method": "unset",
      "protocol": "up",
      "status": "up"
    },
    "GigabitEthernet2.101": {
      "interface_is_ok": "YES",
      "ip_address": "unassigned",
      "method": "unset",
      "protocol": "up",
      "status": "up"
    },
    "GigabitEthernet2.102": {
      "interface_is_ok": "YES",
      "ip_address": "unassigned",
      "method": "unset",
      "protocol": "up",
      "status": "up"
    }
  }
}

It would be fine to have both IPv4 an IPv6 output.

TIA,

Taarini commented 1 year ago

Hi

Thanks for reporting. Since genieparser is community driven. I would like you to create a PR with the potential fix that helps to fix this. Let me know if you need any help in this process.

Taarini commented 1 year ago

Hi

Please let me know whether you're planning to contribute to the community. If not I can add this to our backlog and let you know once it is released.

Taarini commented 1 year ago

Hi

Can you please provide an update, so that we can plan accordingly.