clay584 / parse_genie

Ansible filter plugin for network CLI parsing using Cisco's Genie and pyATS
GNU General Public License v3.0
52 stars 15 forks source link

Parser show ethernet service instance detail for IOS and IOS-XE not working - genie_parse: local variable ''micro_block_dict'' referenced before assignment #2

Closed xcluysen closed 5 years ago

xcluysen commented 5 years ago

Simple Playbook used : `# Test of PyATS / Genie


Result from router command that can't be parsed (extract) :

Service Instance ID: 149
Service Instance Type: Static
Description: Fiber Connexion to XXX-200-2182
Associated Interface: TenGigabitEthernet0/1
Associated EVC:
L2protocol drop
CE-Vlans:
Encapsulation: dot1q 19 vlan protocol type 0x8100 second-dot1q 149 vlan protocol type 0x8100
Rewrite: ingress tag pop 2 symmetric
Interface Dot1q Tunnel Ethertype: 0x8100
State: Up
EFP Statistics:
   Pkts In   Bytes In   Pkts Out  Bytes Out
  36279507 3955205745   42299716 20480433984
EFP Microblocks:
****************
Microblock type: Bridge-domain
Bridge-domain: 149

Microblock type: L2Mcast
L2 Multicast GID: 54

Microblock type: dhcp_snoop
L2 Multicast GID: 54

Service Instance ID: 2001
Service Instance Type: Static
Description: Fiber Connexion (Layer 2) to XXX-200-2183
Associated Interface: TenGigabitEthernet0/1
Associated EVC:
L2protocol drop
CE-Vlans:
Encapsulation: dot1q 21 vlan protocol type 0x8100 second-dot1q 2-148,150-4093 vlan protocol type 0x8100
Rewrite: ingress tag pop 1 symmetric
Interface Dot1q Tunnel Ethertype: 0x8100
State: Up
EFP Statistics:
   Pkts In   Bytes In   Pkts Out  Bytes Out
 356008885 51800659418  533687182 229082305074
EFP Microblocks:
****************
Microblock type: Bridge-domain
Bridge-domain: 4149

Microblock type: L2Mcast
L2 Multicast GID: 54

Microblock type: dhcp_snoop
L2 Multicast GID: 54
clay584 commented 5 years ago

Are you getting an ansible error? What is the output from the efp variable? Is it failing to parse a particular portion of that CLI output?

BTW, this is just the ansible filter plugin that calls Cisco's Genie library. If there is an issue with parsing the data successfully, you will need to file an issue on the GenieParser GitHub page.

xcluysen commented 5 years ago

The router output never get parsed. I get an Ansible/Python error about that variable being referenced before being assigned at execution of genie_parse : genie_parse: local variable ''micro_block_dict'' referenced before assignment So the program aborts before the efp variable gets assigned.

clay584 commented 5 years ago

Can you include the full ansible output so I can see the actual error?

xcluysen commented 5 years ago

Here it is.

I am not an ansible expert yet, if there is more debug available by turning a flag, tell me and I'll do it.

[root@ULYSSE-ANSIBLE Genie Tests Scripts]# ansible-playbook evc.yml

PLAY [pyATS testing] ****

TASK [Read in parse_genie role] *****

TASK [Run the show EFP command] ***** ok: [Eos]

TASK [Set EFP fact with Genie filter plugin] **** fatal: [Eos]: FAILED! => msg: 'genie_parse: local variable ''micro_block_dict'' referenced before assignment - Failed to parse command output.'

PLAY RECAP ** Eos : ok=1 changed=0 unreachable=0 failed=1

jeaubin commented 5 years ago

Hi, genie developer here - it seems an issue with one of our parser. Can you send us your full device output; and we will look into it early next week!

If you prefer for privacy reason, you can send your output at pyats-support-ext@cisco.com

xcluysen commented 5 years ago

Hi,

Please see attached sanitized version of the switch output (only Description field is changed). Acheloos-EFP.txt

Switch is a ME-3600X running IOS 15.4(3)S10.

Same problem/issue with command run on an ASR920-4SZ-A running IOS XE 3.18.4SP4 I also attach the sanitized version, as the output is a little bit different, being IOS XE. Ajax-EFP.txt

jeaubin commented 5 years ago

Great, thanks. We will look into it and let you know.

xcluysen commented 5 years ago

Hi JB,

Thanks for the update, however I get an error when trying to upgrade :

[root@ANSIBLE Genie Tests Scripts]# pip install genie.lis.parser --upgrade --pre Collecting genie.lis.parser ERROR: Could not find a version that satisfies the requirement genie.lis.parser (from versions: none) ERROR: No matching distribution found for genie.lis.parser

Am I missing something ?

Best Regards, Xavier.

jeaubin commented 5 years ago

@xcluysen - I sent it too quickly, This enhancement will be done today/tomorrow.

And ; pip install genie.libs.parser --upgrade --pre

Thanks,

xcluysen commented 5 years ago

Hi JB,

I have installed the latest parser (19.6.1b1), but the playbook gives exactly the same error as before :

TASK [Set EFP fact with Genie filter plugin] *** fatal: [Eos]: FAILED! => msg: 'genie_parse: local variable ''micro_block_dict'' referenced before assignment - Failed to parse command output.'

jeaubin commented 5 years ago

Hi @xcluysen - It has now been released, the fix should work.

pip install genie.libs.parser --upgrade --pre

Let me know if all is good now

Thanks,

clay584 commented 5 years ago

@xcluysen Is this working now? Can I close this issue?

xcluysen commented 5 years ago

@clay584 Yes it works, I sent email but apparently it failed to show here. You can close the issue.