Python Script to convert firewall rules

Jason Friedman jsf80238 at gmail.com
Fri Dec 12 21:31:13 EST 2014


>
>
> 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;
>             }
>         }
>     }
> }
>
>
Note that the practice on this list is to put your response after the
(edited) portion of the previous posts.

Are you willing to learn some Python, if someone gets you started?
Would it be helpful if someone provided Python code to convert this:

set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24

to this:

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

?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141212/d5afb4bf/attachment.html>


More information about the Python-list mailing list