@@ -22,8 +22,16 @@ def check_for_consistency(bgp_device_groups, filter_groups_file_content):
2222 return False
2323 return True
2424
25+ def enrich_routing_policies (group_policies , routing_policies ):
26+ enriched_policies = []
27+ for pol in group_policies :
28+ for i in routing_policies :
29+ if i ['id' ] == pol ['id' ]:
30+ enriched_policies .append (i )
31+ return enriched_policies
2532
26- def build_bgp_device_groups_for_ix_peerings (ix_peerings , connections , as_list ):
33+
34+ def build_bgp_device_groups_for_ix_peerings (ix_peerings , connections , as_list , routing_policies ):
2735 bgp_device_groups = []
2836 for connection in connections :
2937 for ix in ix_peerings :
@@ -91,8 +99,8 @@ def build_bgp_device_groups_for_ix_peerings(ix_peerings, connections, as_list):
9199 ip_version = ip_version ,
92100 max_prefixes = max_prefixes ,
93101 policy_type = policy_type ,
94- import_routing_policies = ix ['import_routing_policies' ],
95- export_routing_policies = ix ['export_routing_policies' ],
102+ import_routing_policies = enrich_routing_policies ( ix ['import_routing_policies' ], routing_policies ) ,
103+ export_routing_policies = enrich_routing_policies ( ix ['export_routing_policies' ], routing_policies ) ,
96104 authentication_key = authentication_key ,
97105 bfd_infos = bfd_infos ,
98106 is_route_server = ix ['is_route_server' ],
@@ -105,7 +113,7 @@ def build_bgp_device_groups_for_ix_peerings(ix_peerings, connections, as_list):
105113 return bgp_device_groups
106114
107115
108- def build_bgp_device_groups_for_direct_peerings (direct_peerings , router ):
116+ def build_bgp_device_groups_for_direct_peerings (direct_peerings , router , routing_policies ):
109117 bgp_device_groups = []
110118 for dp in direct_peerings :
111119
@@ -182,8 +190,8 @@ def build_bgp_device_groups_for_direct_peerings(direct_peerings, router):
182190 max_prefixes = max_prefixes ,
183191 authentication_key = authentication_key ,
184192 policy_type = policy_type ,
185- import_routing_policies = dp ['import_routing_policies' ],
186- export_routing_policies = dp ['export_routing_policies' ],
193+ import_routing_policies = enrich_routing_policies ( dp ['import_routing_policies' ], routing_policies ) ,
194+ export_routing_policies = enrich_routing_policies ( dp ['export_routing_policies' ], routing_policies ) ,
187195 bfd_infos = bfd_infos ,
188196 is_route_server = False ,
189197 )
@@ -199,12 +207,13 @@ def main_bgp(enlighten_manager, sync_manager, peering_manager_instance, hosts=No
199207
200208 e_targets = enlighten_manager .counter (total = 5 , desc = 'Fetching Data' , unit = 'Targets' )
201209
202- with Pool (processes = 5 ) as fetch_pool :
210+ with Pool (processes = 6 ) as fetch_pool :
203211 ix_peerings_res = fetch_pool .apply_async (peering_manager_instance .get_internet_exchange_peerings , ())
204212 direct_peerings_res = fetch_pool .apply_async (peering_manager_instance .get_direct_peerings , ())
205213 routers_res = fetch_pool .apply_async (peering_manager_instance .get_routers , ())
206214 connections_res = fetch_pool .apply_async (peering_manager_instance .get_connections , ())
207215 as_list_res = fetch_pool .apply_async (peering_manager_instance .get_autonomous_systems , ())
216+ routing_policies_res = fetch_pool .apply_async (peering_manager_instance .get_routing_policies , ())
208217
209218 ix_peerings = ix_peerings_res .get ()
210219 e_targets .update ()
@@ -216,6 +225,8 @@ def main_bgp(enlighten_manager, sync_manager, peering_manager_instance, hosts=No
216225 e_targets .update ()
217226 as_list = as_list_res .get ()
218227 e_targets .update ()
228+ routing_policies = routing_policies_res .get ()
229+ e_targets .update ()
219230
220231 e_targets .close ()
221232
@@ -248,9 +259,9 @@ def main_bgp(enlighten_manager, sync_manager, peering_manager_instance, hosts=No
248259
249260 router_connections = list (filter (lambda c : c ['router' ] and c ['router' ]['id' ] == router ['id' ], connections ))
250261
251- bgp_device_groups = build_bgp_device_groups_for_ix_peerings (ix_peerings , router_connections , as_list )
262+ bgp_device_groups = build_bgp_device_groups_for_ix_peerings (ix_peerings , router_connections , as_list , routing_policies )
252263
253- y = build_bgp_device_groups_for_direct_peerings (direct_peerings , router )
264+ y = build_bgp_device_groups_for_direct_peerings (direct_peerings , router , routing_policies )
254265 bgp_device_groups .extend (y )
255266
256267 # Consistency check for filter groups
0 commit comments