Skip to content

Commit

Permalink
Enable controller-less setups
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Heller committed Jan 2, 2010
1 parent 4804237 commit 16c57dd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion bin/mn_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
HOSTS = {'process' : Host}

CONTROLLER_DEF = 'ref'
# a and b are the name and inNamespace params.
CONTROLLERS = {'ref' : Controller,
'nox_dump' : lambda a, b: NOX(a, b, 'packetdump'),
'nox_pysw' : lambda a, b: NOX(a, b, 'pyswitch')}
'nox_pysw' : lambda a, b: NOX(a, b, 'pyswitch'),
'none' : lambda a, b: None}

# optional tests to run
TESTS = ['cli', 'build', 'ping_all', 'ping_pair', 'iperf', 'all']
Expand Down
17 changes: 9 additions & 8 deletions mininet/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def _add_controller(self, controller):
@param controller Controller class
'''
controller = self.controller('c0', not self.kernel)
self.controllers['c0'] = controller
if controller: # allow controller-less setups
self.controllers['c0'] = controller

# Control network support:
#
Expand Down Expand Up @@ -290,15 +291,14 @@ def build(self, xterms, cleanup):
def start(self):
'''Start controller and switches\n'''
lg.info('*** Starting controller\n')
self.controllers['c0'].start()
#for controller in self.controllers:
# controller.start()
for cname, cnode in self.controllers.iteritems():
cnode.start()
lg.info('*** Starting %s switches\n' % len(self.topo.switches()))
for switch_dpid in self.topo.switches():
switch = self.nodes[switch_dpid]
#lg.info('switch = %s' % switch)
lg.info('0x%x ' % switch_dpid)
switch.start(self.controllers['c0'])
switch.start(self.controllers)
lg.info('\n')

def stop(self):
Expand All @@ -316,8 +316,8 @@ def stop(self):
switch.stop()
lg.info('\n')
lg.info('*** Stopping controller\n')
#for controller in self.controllers.iteriterms():
self.controllers['c0'].stop()
for cname, cnode in self.controllers.iteritems():
cnode.stop()
lg.info('*** Test complete\n')

def run(self, test, **params):
Expand Down Expand Up @@ -448,7 +448,8 @@ def __init__(self, mininet):
self.nodemap = {} # map names to Node objects
for node in self.mn.nodes.values():
self.nodemap[node.name] = node
self.nodemap['c0'] = self.mn.controllers['c0']
for cname, cnode in self.mn.controllers.iteritems():
self.nodemap[cname] = cnode
self.nodelist = self.nodemap.values()
self.run()

Expand Down
13 changes: 8 additions & 5 deletions mininet/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,16 @@ def __init__(self, name, datapath = None):
self.dp = datapath
Node.__init__(self, name, inNamespace = (datapath == None))

def _startUserDatapath(self, controller):
def _startUserDatapath(self, controllers):
'''Start OpenFlow reference user datapath.
Log to /tmp/sN-{ofd,ofp}.log.
@param controller Controller object.
@param controllers dict of controller names to objects
'''
if 'c0' not in controller:
raise Exception('User datapath start() requires controller c0')
controller = controllers['c0']
ofdlog = '/tmp/' + self.name + '-ofd.log'
ofplog = '/tmp/' + self.name + '-ofp.log'
self.cmd('ifconfig lo up')
Expand Down Expand Up @@ -302,13 +305,13 @@ def _stopKernelDatapath(self):
quietRun('ip link del ' + intf)
lg.info('.')

def start(self, controller):
def start(self, controllers):
'''Start datapath.
@param controller Controller object
@param controllers dict of controller names to objects
'''
if self.dp is None:
self._startUserDatapath(controller)
self._startUserDatapath(controllers)
else:
self._startKernelDatapath()

Expand Down

0 comments on commit 16c57dd

Please sign in to comment.