-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar.py
executable file
·54 lines (38 loc) · 937 Bytes
/
star.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
#!/usr/bin/python
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.link import TCLink
from mininet.log import setLogLevel
class StarTopo(Topo):
'''
A simple star topology
'''
def build(self, n=3):
switch = self.addSwitch('s1')
for h in xrange(n):
host = self.addHost('h%s' % (h + 1))
self.addLink(host, switch)
def dumpConfigs(net):
'''
Run ifconfig on each host
'''
for hostName, host in net.items():
ifcfgOut = host.cmd('ifconfig')
print hostName + ':'
print ifcfgOut
def testStar():
'''
Test dumpConfigs() on a star topology
'''
topo = StarTopo(n=5)
net = Mininet(topo)
net.start()
print 'Here we go...'
dumpConfigs(net)
print 'Alright, done.'
net.pingAll()
net.stop()
if __name__ == '__main__':
setLogLevel('info')
testStar()
pass