CiscoTestAutomation / genieparser

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

Incorrect parsing for "show interfaces {interface} transceiver detail" #562

Open ravaghi opened 3 years ago

ravaghi commented 3 years ago

The parser fails to convert N/A to float. I tried to remove the type conversion manually, but then I got Parser ShowInterfacesTransceiverDetail schema checking failed.

Traceback (most recent call last):
  File "ssh_test.py", line 244, in <module>
    output = get_interface_transceiver_detail(device, device_port)
  File "ssh_test.py", line 122, in get_interface_transceiver_detail
    transceiver_data = device.parse(f'show interfaces {device_port} transceiver detail')
  File "src/genie/conf/base/device.py", line 524, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 551, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 279, in genie.metaparser._metaparser.MetaParser.parse
  File "/usr/local/lib/python3.6/dist-packages/genie/libs/parser/iosxe/show_interface.py", line 3767, in cli
    intf_dict[stat]['Value'] = float(m.groupdict()['value'])
ValueError: could not convert string to float: 'N/A'
danielgraziano commented 3 years ago

You will also have to change the Value key to optional in the schema like so: Optional('Value'): float