Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82471

Re: Python Script to convert firewall rules

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jsf80238@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'interfaces': 0.04; 'subject:Python': 0.06; 'below)': 0.09; 'converted': 0.09; 'logic': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'address)': 0.16; 'gonna': 0.16; 'optional.': 0.16; 'readability': 0.16; 'started?': 0.16; 'variable': 0.18; 'portion': 0.22; 'cc:addr:python.org': 0.22; 'helpful': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'values': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'reply.': 0.31; 'interface': 0.32; 'convert': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'format.': 0.36; 'interface,': 0.36; 'thanks': 0.36; 'possible': 0.36; 'should': 0.36; 'unit': 0.37; 'list': 0.37; 'previous': 0.38; 'manually': 0.60; 'address': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'yes': 0.68; 'url:17': 0.68; 'family': 0.73
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Z1aosxYXbgw1m6EUFYsutCw9r50OxpphjPaZfzq39Cw=; b=C0AbrZzgadMDfmqkKuHqjq2QCSgxDPnh2MqY9JTKRg5eo2w5hZlJtzQhTiWhUEWnb0 SbcRjp2BsG9olWIGawGManimIR1UTd2rY9xc48pbmmX6JancPUHM+Aq/Yulg9AxnYQci YItXUTmmRcyOFlguJ+umaxZSgwa/p3IC59fuIuWBKG+fH52oaLZM0ukUtZRzpBkezqwL xYx0JMD+eaZFHzAMLpQFfGNOQ1G/G/E1TOHQNy+CEnYK2hkSAadWsZ3tn0ytd3G+lrhw O52wsIEMRQIb9151Cj/b/SMK3scgf2aedp38+qhGv0lF4N0tZkBzYibfQCDowheHiekI UnnQ==
MIME-Version 1.0
X-Received by 10.180.76.7 with SMTP id g7mr13028159wiw.38.1418437873904; Fri, 12 Dec 2014 18:31:13 -0800 (PST)
In-Reply-To <e0d8dd24-2256-4b89-972e-c1ebe82f72a9@googlegroups.com>
References <b23872cc-7b5c-4e38-96c1-ac907b6df7f1@googlegroups.com> <mailman.16883.1418348704.18130.python-list@python.org> <e0d8dd24-2256-4b89-972e-c1ebe82f72a9@googlegroups.com>
Date Fri, 12 Dec 2014 19:31:13 -0700
Subject Re: Python Script to convert firewall rules
From Jason Friedman <jsf80238@gmail.com>
To Kashif Rana <kashifrana84@gmail.com>
Content-Type multipart/alternative; boundary=f46d043893c79c338a050a0fcd99
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16931.1418437882.18130.python-list@python.org> (permalink)
Lines 115
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418437882 news.xs4all.nl 2841 [2001:888:2000:d::a6]:50435
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82471

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

>
>
> 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;
            }
        }
    }
}

?

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Python Script to convert firewall rules Kashif Rana <kashifrana84@gmail.com> - 2014-12-10 10:51 -0800
  Re: Python Script to convert firewall rules Jason Friedman <jsf80238@gmail.com> - 2014-12-11 18:44 -0700
    Re: Python Script to convert firewall rules Kashif Rana <kashifrana84@gmail.com> - 2014-12-11 23:54 -0800
      Re: Python Script to convert firewall rules Jason Friedman <jsf80238@gmail.com> - 2014-12-12 19:31 -0700
        Re: Python Script to convert firewall rules Kashif Rana <kashifrana84@gmail.com> - 2014-12-13 09:41 -0800
          Re: Python Script to convert firewall rules Jason Friedman <jsf80238@gmail.com> - 2014-12-13 18:35 -0700
          Re: Python Script to convert firewall rules Kashif Rana <kashifrana84@gmail.com> - 2014-12-14 10:51 +0400
          Re: Python Script to convert firewall rules Jason Friedman <jsf80238@gmail.com> - 2014-12-14 22:07 -0700

csiph-web