-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathnet.py
More file actions
57 lines (46 loc) · 1.89 KB
/
Copy pathnet.py
File metadata and controls
57 lines (46 loc) · 1.89 KB
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
56
57
"""
Extended "net" module for MiniNExT.
"""
from mininet.log import info
from mininet.net import Mininet
class MiniNExT(Mininet):
"""Override on the default Mininet class to enable use of MiniNExT enabled
hosts"""
def __init__(self, *args, **kwargs):
info("** Using Mininet Extended (MiniNExT) Handler\n")
Mininet.__init__(self, *args, **kwargs)
def configHosts(self):
"Configure the networks hosts."
# Let Mininet handle the baseline initialization
Mininet.configHosts(self)
info('*** Starting host services\n')
for host in self.hosts:
returnCodes = host.autoStartServices()
if returnCodes:
# print detailed information on the started services
statusStr = "%s: " % (host)
for service, returnCode in returnCodes.iteritems():
if returnCode['ret'] == 0:
result = 'OK'
else:
result = 'FAIL'
statusStr += "%s (%s) " % (service, result)
info(statusStr + '\n')
def stop(self):
"Stop the controller(s), switches and hosts"
# First, stop all services in the network
info('*** Stopping host services\n')
for host in self.hosts:
returnCodes = host.autoStopServices()
if returnCodes:
# print detailed information on the stopped services
statusStr = "%s: " % (host)
for service, returnCode in returnCodes.iteritems():
if returnCode['ret'] == 0:
result = 'OK'
else:
result = 'FAIL'
statusStr += "%s (%s) " % (service, result)
info(statusStr + '\n')
# Then, let Mininet take over and stop everything
Mininet.stop(self)