kecorbin / pyats-network-checks

various network health checks using the pyATS Framework
17 stars 10 forks source link

CRC_Count_check.py | Failed reason: local variable 'interface' referenced before assignment #2

Open murmelika opened 5 years ago

murmelika commented 5 years ago

Hi

Testing CRC_Count_check.py example I get the following errors:

(.venv-py36) VEGARCI2-M-N10J:pyats vegarci2$ easypy CRC_check_job.py -testbed_file lab_testbed_g.yaml

... 2019-01-16T18:46:45: %SCRIPT-CRITICAL: local variable 'interface' referenced before assignment 2019-01-16T18:46:55: %AETEST-ERROR: Failed reason: local variable 'interface' referenced before assignment 2019-01-16T18:47:05: %AETEST-INFO: The result of section learn_interfaces is => FAILED 2019-01-16T18:47:35: %AETEST-INFO: Starting section check_CRC 2019-01-16T18:47:35: %AETEST-ERROR: Caught exception during execution: 2019-01-16T18:47:45: %AETEST-ERROR: Traceback (most recent call last): 2019-01-16T18:47:45: %AETEST-ERROR: File "/Users/vegarci2/Documents/pyats/CRC_Count_check.py", line 112, in check_CRC 2019-01-16T18:47:45: %AETEST-ERROR: mega_tabular.append(['-'*sum(len(i) for i in smaller_tabular)]) 2019-01-16T18:47:45: %AETEST-ERROR: UnboundLocalError: local variable 'smaller_tabular' referenced before assignmen ...

I cant find out the RC responsible for these errors.. Please could you give you some insight?

Thanks CRC_check_job_files.zip

murmelika commented 5 years ago

Testing the script with ASR9K works fine, but i still get the error with NCS5508.

Troubleshooting, I see that the parser of the "show interface detail" fails because this is the output received from NCS:

(Pdb) print (out) Tue Jan 22 11:26:42.188 CET b'Bundle-Ether5 is up, line protocol is up \r\n Interface state transitions: 1\r\n Hardware is Aggregated Ethernet interface(s), address is 008a.960f.0483\r\n Description: PRUEBAS VLL IVAN \x96 TRAFICO hacia SORIA\r\n Internet address is 66.66.66.2/30\r\n MTU 1600 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)\r\n reliability 255/255, txload 0/255, rxload 0/255\r\n Encapsulation ARPA,\r\n Full-duplex, 10000Mb/s\r\n loopback not set,\r\n Last link flapped 3d20h\r\n ARP type ARPA, ARP timeout 04:00:00\r\n No. of members in this bundle: 1\r\n TenGigE0/2/0/28/3 Full-duplex 10000Mb/s Active \r\n Last input 00:00:00, output 00:00:00\r\n Last clearing of "show interface" counters never\r\n 5 minute input rate 1000 bits/sec, 2 packets/sec\r\n 5 minute output rate 0 bits/sec, 1 packets/sec\r\n 664870 packets input, 61141676 bytes, 0 total input drops\r\n 0 drops for unrecognized upper-level protocol\r\n Received 0 broadcast packets, 664870 multicast packets\r\n 0 runts, 0 giants, 0 throttles,' 0 parity 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 331745 packets output, 41136324 bytes, 0 total output drops Output 1 broadcast packets, 331744 multicast packets 0 output errors, 0 underruns, 0 applique, 0 resets 0 output buffer failures, 0 output buffers swapped out 0 carrier transitions

Bundle-Ether55 is up, line protocol is up Interface state transitions: 1 Hardware is Aggregated Ethernet interface(s), address is 008a.960f.0482 Description: description Troncal - Alcorcon BE55 - [20G] - py Internet address is 172.23.1.70/31

And this is the first line extracted: (Pdb) print (line) b'Bundle-Ether5 is up, line protocol is up \r\n Interface state transitions: 1\r\n Hardware is Aggregated Ethernet interface(s), address is 008a.960f.0483\r\n Description: PRUEBAS VLL IVAN \x96 TRAFICO hacia SORIA\r\n Internet address is 66.66.66.2/30\r\n MTU 1600 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)\r\n reliability 255/255, txload 0/255, rxload 0/255\r\n Encapsulation ARPA,\r\n Full-duplex, 10000Mb/s\r\n loopback not set,\r\n Last link flapped 3d20h\r\n ARP type ARPA, ARP timeout 04:00:00\r\n No. of members in this bundle: 1\r\n TenGigE0/2/0/28/3 Full-duplex 10000Mb/s Active \r\n Last input 00:00:00, output 00:00:00\r\n Last clearing of "show interface" counters never\r\n 5 minute input rate 1000 bits/sec, 2 packets/sec\r\n 5 minute output rate 0 bits/sec, 1 packets/sec\r\n 664870 packets input, 61141676 bytes, 0 total input drops\r\n 0 drops for unrecognized upper-level protocol\r\n Received 0 broadcast packets, 664870 multicast packets\r\n 0 runts, 0 giants, 0 throttles,' 0 parity (Pdb) Therefore, does not match (P1, line 570 in show_interfaces.py) and interface variable is empty. Later on in show_interfaces.py this interfaces is referenced in the dictionary, but it is empty and the Traceback is raised. Please, is it expected that NCS sends the output with the specified format? Thanks
kecorbin commented 5 years ago

Sorry for the delay let me look into this. unfortunately, I don't have an NCS to test against so it may take a bit to run this down. It looks like a parser issue though, so you may want to raise issue at https://github.com/CiscoTestAutomation/genieparser

jeaubin commented 5 years ago

@murmelika - Thanks for raising this; we are looking into it and will provide a fix.