forked from cnp3/IPMininet-iBGP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_net.py
55 lines (48 loc) · 1.9 KB
/
launch_net.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import ipmininet
from ipmininet.ipnet import IPNet
from ipmininet.cli import IPCLI
from ipmininet.clean import cleanup
from mininet.log import lg, LEVELS
from simple_bgp_network import SimpleBGPTopo
from simple_bgp_community_local_pref import LocalPrefTopo
from simple_bgp_community_local_pref_2 import LocalPref2Topo
from simple_bgp_community_prepend_as import PrependASTopo
from simple_bgp_community_no_advertise import NoAdvertiseTopo
from simple_bgp_community_no_export import NoExportTopo
from simple_bgp_community_gracefull_shutdown import GracefullShutdownTopo
from simple_bgp_community_prepend_as_2 import PrependAS2Topo
from simple_bgp_community_blackhole import BlackholeTopo
import argparse
TOPOS = {
'simple_bgp_network': SimpleBGPTopo,
'simple_bgp_community_local_pref': LocalPrefTopo,
'simple_bgp_community_local_pref_2': LocalPref2Topo,
'simple_bgp_community_prepend_as': PrependASTopo,
'simple_bgp_community_prepend_as_2': PrependAS2Topo,
'simple_bgp_community_no_advertise': NoAdvertiseTopo,
'simple_bgp_community_no_export': NoExportTopo,
'simple_bgp_community_gracefull_shutdown': GracefullShutdownTopo,
'simple_bgp_community_blackhole': BlackholeTopo,
}
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--topo', choices=TOPOS.keys(), default='simple_bgp_network',
help='the topology that you want to start')
parser.add_argument('--log', choices=LEVELS.keys(), default='info',
help='The level of details in the logs')
return parser.parse_args()
if __name__ == '__main__':
args = parse_args()
lg.setLogLevel(args.log)
if args.log == 'debug':
ipmininet.DEBUG_FLAG = True
kwargs = {}
topo = TOPOS[args.topo](**kwargs)
net = IPNet(topo=topo)
try:
net.start()
topo.after_start(net)
IPCLI(net)
finally:
net.stop()
cleanup()