-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhub.py
39 lines (30 loc) · 986 Bytes
/
hub.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
from pox.core import core
import pox.openflow.libopenflow_01 as of
log = core.getLogger()
def launch ():
"""
Launch is the entry point of the module, much like __main__
"""
# Register the hub_component to the system
core.registerNew(HubComponent)
class HubComponent(object):
'''
The hub component is the handler of opendlow events for our
application
'''
def __init__(self):
log.info("Starting HubComponent")
# Make the hub component a listener to openflow events
core.openflow.addListeners(self)
def _handle_ConnectionUp(self, event):
log.info("Creating hub device on %s", event.connection)
# Create a new Hub on the device having this connection
Hub(event.connection)
class Hub(object):
'''
The Hub class is instantiated once for each openflow device
that connects to the hub component. The hub class tranforms the
said device to an ethernet hub
'''
def __init__(self, connection):
log.info("Created hub on switch %s", connection)