Closed alurmtr closed 4 years ago
Hi @alurmtr ,
Could you please send us any log/console output that explains more about the issue?
Thanks, Irene
Ok. I looked at your code. I think the problem is that 'Name' is the description of the Interface and it could be a string that consists of white spaces. So this regex p1 = re.compile(r'(?P\<interface>(\S+)) +(?P\<name>(\S+))? +(?P\<status>(\S+))? +(?P\<vlan>(\S+))' r' +(?P\<duplex_code>(\S+)) +(?P\<port_speed>(\S+)) +(?P\<type>(\S+))$')
The \<name> regex portion should also include white spaces. Hard part here is where "name" ends, and where "status" starts
Hi @alurmtr ,
Thanks for finding out the issue. Could you please create a pull request include this fix?
Checklist for creating a PR:
genieparser/tests
run python -m unittest
,and paste the result into the threadWe'll review your code there.
Thanks, Irene
Ok, i don't have a fix for it. As i mentioned the difficulty lies into when to stop parsing the Name (Description) and when to start the "status". If we knew the list of possible values of Status, that may work?.
Hi @alurmtr ,
Yes, current regex patterns are developed based on the existing outputs we have, we adjust the patterns based on the new sample outputs. So do you have sample outputs for this concern?
Thanks, Irene
hi @xiaoxinz-cisco , see some sample NX-OS outputs below.
The problem condition is: IF interface description contains 1 or more spaces (=Name column) THEN that interface will not be parsed..
N7K-1-LAB# show int status
--------------------------------------------------------------------------------
Port Name Status Vlan Duplex Speed Type
--------------------------------------------------------------------------------
mgmt0 -- connected routed full a-1000 --
Eth1/1 *** N7K-2-FLEXP connected trunk full a-10G SFP-H10GB-C
Eth1/2 *** N7K-2-FLEXP connected trunk full a-10G SFP-H10GB-C
Eth1/3 *** P2P L3-CIS- connected routed full a-1000 1000base-T
Eth1/4 *** FEX 2248TP connected 1 full a-10G Fabric Exte
Eth1/5 *** L2 L3-CIS-N connected trunk full a-1000 1000base-T
Eth1/6 *** L2POE Gi1/0 connected trunk full a-1000 1000base-T
Eth1/7 *** To ACI leaf connected trunk full a-1000 1000base-SX
Eth1/8 -- sfpAbsent routed auto auto --
Eth1/9 -- sfpAbsent routed auto auto --
I noticed that the ios-xe 'show interfaces status' parser correctly takes the spaces in the name field into account
Hello @alurmtr , @MaPiBe
We fixed the issue and genie package v20.4.1b2 has been released with the fix.
Here's the update in regex: https://github.com/CiscoTestAutomation/genieparser/blob/master/src/genie/libs/parser/nxos/show_interface.py#L3398
Could you please run the following command and try again to see if it works?
Please try and let's know if there is an issue.
Thanks, Irene
Hi Irene Thanks for the new fix. Unfortunately this did not work. Looking at your code looks like you expect a "**" to prepend the \<name>. \<name> should be any string including spaces. If you remove (**\\s) from your code, it works great.
Hi @alurmtr ,
Thanks for the feedback, we fixed the regex-patterns based on the above examples, if there are other cases, would you mind updating it and create a pull request?
Thanks, Irene
Hi Irene.
ok. i understand. However, the fix made here is specific to a \<name> that starts with . There is no requirement that a name(description) must start with . The original description of the issue is that it needs to support any string including white space. Here an example
Eth1/12 FRG45 1RT-34 TM connected 1 full 10G 10Gbase-SR
where name, in this example, is : FRG45 1RT-34 TM
Al/
Hi @alurmtr ,
Thanks for providing this new output.
In your initial question description plus sample output, we assumed you were talking about the space of *** FEX 2248TP
within Eth1/4 *** FEX 2248TP connected 1 full a-10G Fabric Exte
, which is handled in this fix.
Okay, now we need to come up with a solution for Eth1/12 FRG45 1RT-34 TM connected 1 full 10G 10Gbase-SR
. Since the genieparser is open-sourced, you would benefit from your own fix immediately, compared with waiting for our release.
Also, it's a plain regex issue, we'd suggest you modify or create a regex pattern, and create a pull request. Our team will review and merge it.
regex101.com could help while you're playing around with regex.
Let me know if it works for you. :)
Thanks, Irene
Ok, i submitted a pull request for review. Thanks Al
Hi @alurmtr ,
Thanks for your contribution, we'll review #156 and give you feedback there.
Thanks, Irene
If a description is configured in an interface, parse_genie "show interface status" does not list it.