Python Script to convert firewall rules

Kashif Rana kashifrana84 at gmail.com
Fri Dec 12 02:54:33 EST 2014


Hi Jason

Thanks for the reply. Yes I can make the all possible keywords/values for both formate. But after that what gonna be the logic to convert one format to other format. Like to convert one line below are the keywords:

set interface ethernet2/5 ip 10.17.10.1/24 (format 1)
set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24 (format 2)

(set, interface, ip) = (set, interfaces, family inet address)

But some values are variable and should ask the user to convert manually like ethernet2/5 equal to ge-0/0/0 or ge-0/0/1 or ge-0/0/2

And some values keep as it is like 10.17.10.1/24 

Also then format 2 can be converted int o format 3 (as below) for more readability of format 2. This is just optional. 

interfaces {  
    ge-2/0/5 { 
        unit 0 { 
            family inet { 
                address 10.17.10.1/24; 
            } 
        } 
    } 
}

On Friday, December 12, 2014 5:45:20 AM UTC+4, Jason Friedman wrote:
> I am network engineer and not expert in programming. I would like to make one python script to convert juniper netscreen firewall configuration into juniper SRX firewall configuration.
> 
> 
> 
> Looks pretty tricky, do you have a specification for each format containing all the possible keywords/values?
> 
> 
> If you could describe the logic in English then writing the equivalent in Python would be straightforward for many people on this list.



More information about the Python-list mailing list