-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.py
55 lines (41 loc) · 1.39 KB
/
router.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
from mininet.node import Switch
from mininet.util import (quietRun, errRun, errFail, moveIntf, isShellBuiltin,
numCores, retry, mountCgroups)
from mininet.moduledeps import moduleDeps, pathCheck, OVS_KMOD, OF_KMOD, TUN
from mininet.link import Link, Intf, TCIntf
from mininet.log import info, error, warn, debug
class Router(Switch):
"Bridge switch."
def __init__(self, name, **params):
super(Router, self).__init__(name, **params)
@classmethod
def setup(cls):
return True
def dpctl(self, *args):
return True
def attach(self, intf):
"Connect a data port to the bridge"
self.cmd('ifconfig', intf, 'up')
self.TCReapply(intf)
def detach(self, intf):
"Disconnect a data port"
self.cmd('ifconfig', intf, down)
def deleteIntfs(self, checkName=True):
super(Router, self).deleteIntfs()
def controllerUUIDs(self):
"Return ovsdb UUIDs for our controllers"
uuids = []
return uuids
def connected(self):
return True
@staticmethod
def TCReapply(intf):
if type(intf) is TCIntf:
intf.config(**intf.params)
def start(self, controllers):
self.cmd('ifconfig lo up')
self.cmd('ifconfig', self, 'up')
def stop(self):
"Terminate OVS switch."
self.cmd('ifconfig', self, 'down')
self.deleteIntfs()