Text
FSM
- Python module/library to get structured data out of raw data got from a network device( Routers and Switches )
- TextFSM is a template based state machine built by Google to simplify dealing with Regular Expressions and getting data from traditional network devices
Consider a sample input:
VLAN
Type Vlan-mode
----
----- ----------
1 enet
CE
2 enet
CE
3 enet
CE
4 enet
CE
5 enet
CE
Sample
FSM Template that will define the data we want to extract:
Value
VLAN_ID (\d+)
Value
TYPE (\w+)
Value
MODE (\w+)
First variables are defined. Next to each variable name is the regular expression that represents it.
The
FSM code to parse the required information looks like :
Start
^${VLAN_ID}\s+${TYPE}\s+${MODE}\s+ ->
Record
Makes your life easy while working with pattern matching : http://www.regexr.com/
Further
Reading – Official Documentation https://code.google.com/archive/p/textfsm/wikis/TextFSMHowto.wiki
No comments:
Post a Comment