sk2 / ank_legacy_v2

Legacy edition of autonetkit. Please see https://github.com/sk2/autonetkit for latest version
www.autonetkit.org
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

dynagen policy flattening #167

Closed sk2 closed 12 years ago

sk2 commented 12 years ago
(asn = 1) egress-> (asn = 2): (if tag = cde then addTag a300) else (if tag = def then setMED 200) 
(asn = 1) egress-> (asn = 2): (if tag = ghi then addTag a300)           
(asn = 2) ->ingress (asn = 1): (if tag = xyz then setLP 100)          
(asn = 2) ->ingress (asn = 1): (if tag = zzz then setLP 150 & reject route)  

gives on hostname 1c_AS1

 neighbor 10.1.0.50 remote-as 1
 neighbor 10.1.0.50 update-source loopback 0
 neighbor 10.1.0.50 send-community
 neighbor 10.1.0.50 route-map rm_1c_AS1_in in   
 neighbor 10.1.0.50 route-map rm_1c_AS1_out out
 neighbor 10.1.0.66 remote-as 1
 neighbor 10.1.0.66 update-source loopback 0
 neighbor 10.1.0.66 send-community
 neighbor 10.1.0.67 remote-as 1
 neighbor 10.1.0.67 update-source loopback 0
 neighbor 10.1.0.67 send-community     
route-map rm_1c_AS1_in permit 10
 match community xyz;
 set local-preference 100
 continue
route-map rm_1c_AS1_in deny 20
 match community zzz;
 set local-preference 150
!
route-map rm_1c_AS1_out permit 10
 match community cde;
 set community 1234:20 additive
 continue
route-map rm_1c_AS1_out permit 20
 match community def;
 set metric 200
 continue
route-map rm_1c_AS1_out permit 30
 match community ghi;
 set community 1234:20 additive
!

from abstract policy:

 ('1c.AS1', '2a.AS2'): {'egress': [rm_egress_2a_AS2_1 [seq 1 if [tag = cde] then [addTag a300] reject: False, seq 2 if [tag = def] then [setMED 200] reject: False],
                                   rm_egress_2a_AS2_2 [seq 1 if [tag = ghi] then [addTag a300] reject: False]],
                        'ingress': [rm_ingress_1c_AS1_1 [seq 1 if [] then [setLP 200] reject: False]]},
 ('2a.AS2', '1c.AS1'): {'egress': [],
                        'ingress': [rm_ingress_2a_AS2_1 [seq 1 if [tag = xyz] then [setLP 100] reject: False],
                                    rm_ingress_2a_AS2_2 [seq 1 if [tag = zzz] then [setLP 150] reject: True]]},
sk2 commented 12 years ago

implemented.