I've a task to parse Cisco ACE config. I'm using python textFSM module. This template should parse "serverfarm " part of the config:
Value Required Serverfarm_name (\S+)
Value load_balance_method (\S+)
Value probe_name (\S+)
Value List rserver_name (\S*)
Start
^serverfarm\s+host\s+$Serverfarm_name
^\s+predictor\s+$load_balance_method
^\s+probe\s+$probe_name
^\s+rserver\s+$rserver_name -> RServer
RServer
^\s+rserver\s+$rserver_name -> Continue.Record
^\s+inservice
Part of the Cisco ACE config: ......
serverfarm host SF-TEST1-3.8083
predictor hash address source
probe TEST-3.8083
rserver lala_server438
inservice
rserver lala_server439
inservice
serverfarm host SF-TEST1-4.8084
predictor hash address source
probe TEST-4.8084
rserver lala_server438
inservice
rserver lala_server439
inservice
serverfarm host SF-TEST1-5.8085
predictor hash address source
probe TEST-5.8085
rserver lala_server438
inservice
rserver lala_server439
inservice
......
After running ace.py script I don't have desired result as a textFSM table :
$ ./ace.py
--- [2018-05-30 16:47:52.892697] --- Start Timestamp ---
--- [+0.000116 sec] --- Parse: ./textFSM/ace_serverfarm_template.textfsm ---
['Serverfarm_name', 'load_balance_method', 'probe_name', 'rserver_name']
['SF-TEST1-3.8083', 'hash', 'TEST-3.8083', ['lala_server438', 'lala_server439']]
Write 1 records
What is my error in the template file? How to change it in order to parse every serverfarm. (I've only first record as a result)?
I found temporary solution for this but it'll be more convinient to make rserver column fields as a "List" of rservers.
Workaround:
But this will produce more rows in the FSM table. If I've let's say 4 servers for one serverfarm there will be 4 rows .. not one.
Somebody with am idea how to change the template in order to get one row per serverfarm and list of rservers as a field in the last column "rserver_name"
Output: