I need to extract the data elements in a data file containing curly brace neted data to produce a list of NAT pairs. For example, here is a dump from our Palo Alto FW:
------------------ Sample input { { { Prod1_Core_10.2.6.1 { to WAN; from WAN; source any; destination 8.39.63.3; service service-https; to-interface any; destination-translation { translated-address 10.2.6.1; } description "Static NAT to Core 10.2.6.1"; } Prod1_Core_10.2.6.2 { to WAN; from WAN; source any; destination 8.39.63.4; service service-https; to-interface any; destination-translation { translated-address 10.2.6.2; } description "Static NAT to Core 10.2.6.2"; } } } end sample input ---------------
Essentially, we want to extract these values:
>>>> Prod1_Core_10.2.6.2 { to WAN; from WAN; source any; >>>> destination 8.39.63.4; service service-https; to-interface any; destination-translation { >>>> translated-address 10.2.6.2; <<<<
From this data we need to produce a list of the nat pairs like:
queue = [ {:corename => "Prod1_Core_10.2.6.1", :pubip => "8.39.63.3", :privip + => "10.2.6.1"}, {:corename => "Prod1_Core_10.2.6.2", :pubip => "8.39.63.4", :privip +=> "10.2.6.2"}, ]
Is there a parser that will be able to map the data blocks in the nested data into single entities like a string?
any guidance is greatly appreciated :)
Daniel
2018-05-02 Athanasius changed pre to paragraph and code tags
In reply to Parsing { } nested data in a file by daniel99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |