I'm new to TextFSM and I'm trying to parse a BigIP F5 config using TextFSM. The final results only capturing one profile out of multiple profiles associated with a virtual server. I'm trying to get all of them captured.
I already tried a lot of TextFSM combination of commands but maybe I just fail to understand how it properly works.
Input
ltm virtual /Common/Cust_A_Virtual_Server {
destination /Common/10.10.10.10:443
ip-protocol tcp
mask 255.255.255.255
pool /Common/Cust_A_pool
profiles {
/Common/Cust_A_SSL {
context clientside
}
/Common/Cust_A_http { }
/Common/tcp { }
}
rules {
/Common/Cust_A_iRule
}
source 0.0.0.0/0
translate-address enabled
translate-port enabled
vlans {
/Common/Cust_A_v1100
}
vlans-enabled
}
Current Result
{
"virtual": "Cust_A_Virtual_Server",
"virtualpart": "Common",
"vprof": "tcp",
"vprofpart": "Common"
}
Desired Result
{
"virtual": "Cust_A_Virtual_Server",
"virtualpart": "Common",
"vprof": ["Cust_A_SSL","Cust_A_http","tcp"]
"vprofpart": ["Common","Common","Common"]
}
I used below TextFSM template to get above "Current Result"
Value Filldown virtual (\S+)
Value Filldown virtualpart (\S+)
Value Required vprof ([a-zA-Z\/\-0-9.]+(?!:))
Value vprofpart (\S+)
Start
^ltm\svirtual\s\/${virtualpart}\/${virtual} -> Continue
^\s+profiles\s[{]\n+ -> Continue.Record
^\s+\/${vprofpart}\/${vprof}\s[{] -> Continue.Record
I'm not familiar with TextFSM but wondering if instead of pulling from bigip.conf, grabbing from the REST API and re-working that output instead?
GET https:///mgmt/tm/ltm/virtual/<name_of_virtual>
and
GET https:///mgmt/tm/ltm/virtual/<name_of_virtual>/profiles
Two things can help here: List option and the state transition . Template:
Value virtual (\S+)
Value virtualpart (\S+)
Value List vprof (\S+)
Value List vprofpart (\S+)
Start
^ltm\svirtual\s/${virtualpart}/${virtual}
^\s+profiles -> Profiles
Profiles
^\s+/${vprofpart}/${vprof}\s{
^\s+rules -> Record Start
Result:
{'virtual': 'Cust_A_Virtual_Server',
'virtualpart': 'Common',
'vprof': ['Cust_A_SSL', 'Cust_A_http', 'tcp'],
'vprofpart': ['Common', 'Common', 'Common']}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.