forked from cnp3/IPMininet-iBGP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_bgp_community_prepend_as.py
35 lines (30 loc) · 1.18 KB
/
simple_bgp_community_prepend_as.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from ipmininet.router.config import BGP, CommunityList
from ipmininet.router.config.zebra import RouteMapSetAction
from simple_bgp_network import SimpleBGPTopo
class PrependASTopo(SimpleBGPTopo):
def create_community_lists(self):
community_list = CommunityList(
'prepend-as-list', community='2:90')
return [community_list]
def set_route_maps_for_community(self, community_list, as1r1, as2r1, as2r2, as3r1):
for route_map_name in ['as3r1-ipv4-out', 'as3r1-ipv6-out']:
as2r2.get_config(BGP).add_set_action(
name=route_map_name,
direction='out',
peer=as3r1,
matching=(community_list,),
set_action=RouteMapSetAction(
'comm-list',
f'{community_list.name} delete'
)
)
as2r2.get_config(BGP).add_set_action(
name=route_map_name,
direction='out',
peer=as3r1,
matching=(community_list,),
set_action=RouteMapSetAction(
'as-path',
'prepend 2'
)
)