Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template update: cisco_ios_show_vlan to get interface list #175

Closed
lboue opened this issue Jan 18, 2018 · 4 comments · Fixed by #210
Closed

Template update: cisco_ios_show_vlan to get interface list #175

lboue opened this issue Jan 18, 2018 · 4 comments · Fixed by #210

Comments

@lboue
Copy link

lboue commented Jan 18, 2018

Hello,

I am trying to improve your template called cisco_ios_show_vlan.template to get interface list for each VLAN
You can see that this file cisco_ios_show_vlan.raw contains "Ports" column.

ISSUE TYPE

I have an issue with the Template Creation

TEMPLATE USING
Value VLAN_ID (\d+)
Value NAME (\S+)
Value STATUS (\S+)
Value List PORTS (\S.+)

Start
  ^VLAN\s+Type -> Done
  ^${VLAN_ID}\s+${NAME}\s+${STATUS}\s+$PORTS -> Record
  ^\s+$PORTS -> Record
SAMPLE COMMAND OUTPUT
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/1
10   Management                       active    
50   VLan50                           active    Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12
60   VLan60                           active    Fa0/13, Fa0/14, Fa0/15, Fa0/16, Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                Fa0/21, Fa0/22, Fa0/23, Fa0/24
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0   
10   enet  100010     1500  -      -      -        -    -        0      0   
50   enet  100050     1500  -      -      -        -    -        0      0   
60   enet  100060     1500  -      -      -        -    -        0      0   
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    srb      0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
SUMMARY

I new some help to fix my template proposal because I don't how to copy VLAN_ID variable for the second to N row for each VLAN.

STEPS TO REPRODUCE

Apply the previous template against cisco_ios_show_vlan.raw

EXPECTED RESULTS
---
parsed_sample:

 - vlan_id: '1'
   name: 'default'
   status: 'active'
   ports: 'Gi0/1'

 - vlan_id: '10'
   name: 'Management'
   status: 'active'

 - vlan_id: '50'
   name: 'VLan50'
   status: 'active'
   ports: Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8, Fa0/9, Fa0/10, Fa0/11, Fa0/12

 - vlan_id: '60'
   name: 'VLan60'
   status: 'active'
   ports: Fa0/13, Fa0/14, Fa0/15, Fa0/16, Fa0/17, Fa0/18, Fa0/19, Fa0/20, Fa0/21, Fa0/22, Fa0/23, Fa0/24

 - vlan_id: '1002'
   name: 'fddi-default'
   status: 'act/unsup'

 - vlan_id: '1003'
   name: 'token-ring-default'
   status: 'act/unsup'

 - vlan_id: '1004'
   name: 'fddinet-default'
   status: 'act/unsup'

 - vlan_id: '1005'
   name: 'trnet-default'
   status: 'act/unsup'
ACTUAL RESULTS

Regards,
Ludovic

@itdependsnetworks
Copy link
Contributor

Ludovic,

There is really only a hack way around this, I have asked to extend the capability from the developers, but have not heard back. Adding a +1 may help to highlight the issues: google/textfsm#18

@lboue
Copy link
Author

lboue commented Jan 22, 2018

Hello Ken ,

Thanks for asking RepeatedItem to the developers.
I managed to get close to the expected result. But I still have to split the PORTS value in an external script.

Value NAME (\S+)
Value STATUS (\S+)
Value List PORTS (\S.+)

Start
  ^VLAN\s+Type -> Done
  ^\S -> Continue.Record
  ^${VLAN_ID}\s+${NAME}\s+${STATUS}\s+${PORTS}
  ^${VLAN_ID}\s+${NAME}\s+${STATUS}
  ^\s+${PORTS}

Done

Here is the result a this template against your raw file cisco_ios_show_vlan.raw

python textfsm.py vlan.tmpl cisco_ios_show_vlan.raw
FSM Template:
Value VLAN_ID (\d+)
Value NAME (\S+)
Value STATUS (\S+)
Value List PORTS (\S.+)

Start
  ^VLAN\s+Type -> Done
  ^\S -> Continue.Record
  ^${VLAN_ID}\s+${NAME}\s+${STATUS}\s+${PORTS}
  ^${VLAN_ID}\s+${NAME}\s+${STATUS}
  ^\s+${PORTS}

Done


FSM Table:
['VLAN_ID', 'NAME', 'STATUS', 'PORTS']
['1', 'default', 'active', ['Gi0/1']]
['10', 'Management', 'active', []]
['50', 'VLan50', 'active', ['Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5, Fa0/6, Fa0/7, Fa0/8, Fa0/9', 'Fa0/10, Fa0/11, Fa0/12']]
['60', 'VLan60', 'active', ['Fa0/13, Fa0/14, Fa0/15, Fa0/16, Fa0/17, Fa0/18, Fa0/19, Fa0/20', 'Fa0/21, Fa0/22, Fa0/23, Fa0/24']]
['1002', 'fddi-default', 'act/unsup', []]
['1003', 'token-ring-default', 'act/unsup', []]
['1004', 'fddinet-default', 'act/unsup', []]
['1005', 'trnet-default', 'act/unsup', []]

Can I send a merge request?

Regards,
Ludovic

@itdependsnetworks
Copy link
Contributor

Can you take a look at what was done here:

^${BUNDLE_IFACE}${BUNDLE_STATUS}\s+${BUNDLE_PROTO}${BUNDLE_PROTO_STATE}\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^Po\d+\(\w+\)\s+\w+\(\w+\)\s+Et.+?\(.+?\)\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^Po\d+\(\w+\)\s+\w+\(\w+\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^Po\d+\(\w+\)\s+\w+\(\w+\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^Po\d+\(\w+\)\s+\w+\(\w+\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^Po\d+\(\w+\)\s+\w+\(\w+\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+Et.+?\(.+?\)\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
?

@jmcgill298
Copy link
Contributor

@lboue I put together something last night. I think it is good, but it was getting late, so I need to review it again; then I will put in a PR for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants