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: 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: References: Date: Fri, 12 Dec 2014 19:31:13 -0700 Subject: Re: Python Script to convert firewall rules From: Jason Friedman To: Kashif Rana Content-Type: multipart/alternative; boundary=f46d043893c79c338a050a0fcd99 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --f46d043893c79c338a050a0fcd99 Content-Type: text/plain; charset=UTF-8 > > > 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; } } } } ? --f46d043893c79c338a050a0fcd99 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Thanks for the reply. Yes I can make the all possible keywords/values for b= oth formate. But after that what gonna be the logic to convert one format t= o 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) =3D (set, interfaces, family inet address)

But some values are variable and should ask the user to convert manually li= ke 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 read= ability of format 2. This is just optional.

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


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 b= e helpful if someone provided Python code to convert this:

set inter= faces ge-0/0/0 unit 0 family inet address 10.17.10.1/24

to this:

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

?
--f46d043893c79c338a050a0fcd99--