Giter VIP home page Giter VIP logo

go-textfsm's People

Contributors

ali-aqrabawi avatar neermitt avatar tobieiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-textfsm's Issues

Value options causes MISSINGARGUMENT parser error

parseVal should accept value options like Required, List, Filldown and Fillup

template example:

Value Required INTF (\S+)
Value IPADDR (\S+)
Value STATUS (down|up)
Value PROTO (up|down)

Start
  ^${INTF}\s+${IPADDR}\s+\w+\s+\w+\s+${STATUS}\s+${PROTO} -> Record

reference

multiple Records in same state support

in textFSM you can have multiple records in same state, and when ever you reach to a cmd/line with a record you should add a new record and move to the next line in data.

in go-textFSM it continue on same line and add new record,

for example :

Value Slot (\d)
Value State (\w+)
Value Temperature (\d+)
Value DRAM (\d+)
Value Buffer (\d+)

Start
  # We can't use .* for unused placeholders, as greedy matching will break it.
  ^\s+${Slot}\s+${State}\s+${Temperature}\s+\d+\s+\d+\s+${DRAM}\s+\d+\s+${Buffer} -> Record
  ^\s+${Slot}\s+${State} -> Record

data:

  Slot State            (C)  Total  Interrupt      DRAM (MB) Heap     Buffer
 0  Online            24      7          0       256        38         51
 1  Online            25      7          0       256        38         51
 2  Online            24      3          0       256        37         49
 3  Online            23      3          0       256        37         49
 4  Empty
 5  Empty
 6  Empty
 7  Empty

in go-textfsm the results will be

 [0 Online 24 256 51]  
 [0 Online   ]               <- duplicate record on same line
 [1 Online 25 256 51]
 [1 Online   ]               <- duplicate record on same line
 [2 Online 24 256 49]
 [2 Online   ]               <- duplicate record on same line
 [3 Online 23 256 49]
 [3 Online   ]               <- duplicate record on same line
 [4 Empty   ]
 [5 Empty   ]
 [6 Empty   ]
 [7 Empty   ]

it should be

 [0 Online 24 256 51]
 [1 Online 25 256 51]
 [2 Online 24 256 49]
 [3 Online 23 256 49]
 [4 Empty   ]
 [5 Empty   ]
 [6 Empty   ]
 [7 Empty   ]

Parsing Of Value Stored As Variable

I am unsure if this is currently supported or not but I am trying to figure out the best way to create a template that can leverage A Record of the value as the item to search for. I guess the best example I can give is something like the following:

router bgp
local-asn 1299
neighbor 1.1.1.1 remote-asn 1987

address-family ipv4 unicast
neighbor 1.1.1.1 route-policy allow-all in
neighbor 1.1.1.1 route-policy allow-all out
exit-context

What I am trying to do is basically have the following template:

Value Filldown ProcessASN (\d+)
Value Neighbor (\S+)
Value Filldown AddressFamily (ipv\d)
Value RPInbound (\S+)
Value RPEgress (\S+)

Start
  ^.*router bgp
  ^.*local-asn ${ProcessASN} -> AddressFamily

AddressFamily
  ^.*address-family ${AddressFamily} unicast -> BGP

BGP
  ^.*neighbor ${Neighbor} -> Continue
  ^.*neighbor ${Neighbor} route-policy ${RoutePolicyIn} in -> Continue
  ^.*neighbor ${Neighbor} route-policy ${RoutePolicyOut} out -> Continue Record
  ^.*exit-context -> AFI

The above would produce:

["1299","ipv4","1.1.1.1","allow-all","allow-all"]

I am wondering if it is possible to lookup the actual BGP neighbor when transitioning the state to BGP, so the output would look more like:

["1299","1.1.1.1","1897","ipv4","allow-all","allow-all"]

current status

Hi,
I have a interest in helping out on this library, What is the current status?

Required Seems Not To Be Working The Same As In Python's TFM

I have started looking into this but it appears that the Required is not working as expected.

Test Config Source:
testConfig.txt

Test Template:
lsp.txt

When running this in python's textfsm I receive what I expect:

[['5455', 'RTRA->RTRB->LAB', 'Loopback65', '8.8.8.8']]

But when running with go I get the following:

[   15.21.66.154]
[5455 RTRA->RTRB->LAB Loopback65 8.8.8.8]

I would assume that since it is required that it shouldn't add the first Row at all.

CLI like textfsm

I think we need an CLI like textfsm. With that it's easier to explain some examples #2 .

end of line (i.e $$) and `?` support

end of line in textFSM should be optional and defined by user using $$,

  1. go-textfsm append each matchingLine with $ which making it not optional.
  2. also it does not accept $$ and raises illegal token if exist in template.
  3. go-textfsm does not accept ? char.

Parser does not return the variable names

Python TextFSM parser returns the names of the variables as the first row. It is useful to match the data and the corresponding variables in the presence of optional variables.

It is crucial to have the same behavior in go-textfsm as well.

wrong recording

go-textfsm is recording a Columns instead of Raws.

for example,
template :

Value IFACE (\S+)
Value Required NAME (\S+)
Value STATUS (down|up)
Value ERROR (.*)

Start
  ^Interface:\s+${IFACE}
  ^\s+name\s+"${NAME}"
  ^\s+status\s+${STATUS}
  ^\s+errors:\s+${ERROR} -> Record

input file:

Interface: Gi0/1
    name "wan1"
    status up
    errors: output Queue errors
Interface: Gi0/2
    name "wan2"
    status down
    errors: input Queue errors

in go-textfsm the records will be like :

[Gi0/1 Gi0/2]
[wan1 wan2 ]
[up down]
[output Queue errors input Queue errors]

while in google/textfsm it will be :

['Gi0/1', 'wan1', 'up', 'output Queue errors']
['Gi0/2', 'wan2', 'down', 'input Queue errors']

Parser captures incorrect value

Please look at the attached template and text file.

The value of bar should be 300 but it is 200 - probably because the string to match is Bar and it is a suffix of FooBar.

Expected output:
"100" "300"

Actual output:
"100" "200"
"" 300

template.txt
test.txt

Issue - Duplicate Rows Are Recorded - Python TextFSM Tests Proper

I am testing the following template and config.

Template:
https://gist.github.com/metajar/9965f7ed135a24acd1fc455f88d319bc

Test Config:
https://gist.github.com/metajar/63362dd0273fa0388d784edd2c56e2ab

In python I receive:

['192.168.74.22', '', 'INERNALCPE', 'INTERNAL:CPE:ROUTEREFLECTOR', '', '']
['192.168.74.23', '', 'INERNALCPE', 'INTERNAL:CPE:ROUTEREFLECTOR', '', '']
['192.168.74.24', '', 'INERNALCPE', 'INTERNAL:CPE:ROUTEREFLECTOR', '', '']
['192.168.74.25', '', 'INERNALCPE', 'INTERNAL:CPE:ROUTEREFLECTOR', '', '']
['172.31.255.11', '', 'EXTERNALBLUE', 'EXTERNAL:CPE:ROUTEREFLECTOR', 'reject', 'reject']
['1.1.1.1', '808', '808HAWAII', 'EXTERNAL:CUSTOMER:808', '', '']
['2.2.2.2', '', '1299TT', 'FULLROUTES:TT', '', 'TT']
['19.12.12.1', '', '19NG', 'INTERNAL:ROUTES:VPN', 'reject-some', 'reject-them']
['32.12.12.12', '9999', 'BLACKHOLE', 'EXTERNAL:SERVICEVPN:100', '', '']
['23.23.23.23', '9082', '23S-policy', 'EXTERNAL:SERVICEVPN:200', '', '']

But unfortunately with the Go-TextFSM I see the following:

["192.168.74.23" "" "INERNALCPE" "INTERNAL:CPE:ROUTEREFLECTOR" "" ""]
["192.168.74.23" "" "INERNALCPE" "INTERNAL:CPE:ROUTEREFLECTOR" "" ""]
["192.168.74.24" "" "INERNALCPE" "INTERNAL:CPE:ROUTEREFLECTOR" "" ""]
["192.168.74.25" "" "INERNALCPE" "INTERNAL:CPE:ROUTEREFLECTOR" "" ""]
["172.31.255.11" "" "EXTERNALBLUE" "EXTERNAL:CPE:ROUTEREFLECTOR" "reject" "reject"]
["172.31.255.11" "" "EXTERNALBLUE" "EXTERNAL:CPE:ROUTEREFLECTOR" "reject" "reject"]
["2.2.2.2" "808" "808HAWAII" "EXTERNAL:CUSTOMER:808" "reject" "reject"]
["2.2.2.2" "808" "1299TT" "FULLROUTES:TT" "reject" "TT"]
["2.2.2.2" "808" "1299TT" "FULLROUTES:TT" "reject" "TT"]
["19.12.12.1" "808" "19NG" "INTERNAL:ROUTES:VPN" "reject-some" "reject-them"]
["19.12.12.1" "808" "19NG" "INTERNAL:ROUTES:VPN" "reject-some" "reject-them"]
["32.12.12.12" "9999" "BLACKHOLE" "EXTERNAL:SERVICEVPN:100" "reject-some" "reject-them"]
["23.23.23.23" "9082" "23S-policy" "EXTERNAL:SERVICEVPN:200" "reject-some" "reject-them"]
["23.23.23.23" "9082" "23S-policy" "EXTERNAL:SERVICEVPN:200" "reject-some" "reject-them"]

Is there something within the templating that I need to change to work with Go-TextFSM?

Value with Record action is considered to be mandatory

test.txt
template.txt

PFA the template and text files.

Expected output:
foo bar xyz
"100" "200" ""
(This is the output from Python TextFSM library.)

Actual output:
(Empty)

The value xyz is treated as mandatory probably because it appears along with the Record action in the template.

Actually the Record action itself is not mandatory. This is another deviation from the original Python library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.