Enable controller-less setups

This commit is contained in:
Brandon Heller
2010-01-02 10:58:28 -08:00
parent 4804237fa7
commit 16c57ddb33
3 changed files with 20 additions and 14 deletions
+3 -1
View File
@@ -30,9 +30,11 @@ HOST_DEF = 'process'
HOSTS = {'process' : Host} HOSTS = {'process' : Host}
CONTROLLER_DEF = 'ref' CONTROLLER_DEF = 'ref'
# a and b are the name and inNamespace params.
CONTROLLERS = {'ref' : Controller, CONTROLLERS = {'ref' : Controller,
'nox_dump' : lambda a, b: NOX(a, b, 'packetdump'), '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 # optional tests to run
TESTS = ['cli', 'build', 'ping_all', 'ping_pair', 'iperf', 'all'] TESTS = ['cli', 'build', 'ping_all', 'ping_pair', 'iperf', 'all']
+9 -8
View File
@@ -161,7 +161,8 @@ class Mininet(object):
@param controller Controller class @param controller Controller class
''' '''
controller = self.controller('c0', not self.kernel) controller = self.controller('c0', not self.kernel)
self.controllers['c0'] = controller if controller: # allow controller-less setups
self.controllers['c0'] = controller
# Control network support: # Control network support:
# #
@@ -290,15 +291,14 @@ class Mininet(object):
def start(self): def start(self):
'''Start controller and switches\n''' '''Start controller and switches\n'''
lg.info('*** Starting controller\n') lg.info('*** Starting controller\n')
self.controllers['c0'].start() for cname, cnode in self.controllers.iteritems():
#for controller in self.controllers: cnode.start()
# controller.start()
lg.info('*** Starting %s switches\n' % len(self.topo.switches())) lg.info('*** Starting %s switches\n' % len(self.topo.switches()))
for switch_dpid in self.topo.switches(): for switch_dpid in self.topo.switches():
switch = self.nodes[switch_dpid] switch = self.nodes[switch_dpid]
#lg.info('switch = %s' % switch) #lg.info('switch = %s' % switch)
lg.info('0x%x ' % switch_dpid) lg.info('0x%x ' % switch_dpid)
switch.start(self.controllers['c0']) switch.start(self.controllers)
lg.info('\n') lg.info('\n')
def stop(self): def stop(self):
@@ -316,8 +316,8 @@ class Mininet(object):
switch.stop() switch.stop()
lg.info('\n') lg.info('\n')
lg.info('*** Stopping controller\n') lg.info('*** Stopping controller\n')
#for controller in self.controllers.iteriterms(): for cname, cnode in self.controllers.iteritems():
self.controllers['c0'].stop() cnode.stop()
lg.info('*** Test complete\n') lg.info('*** Test complete\n')
def run(self, test, **params): def run(self, test, **params):
@@ -448,7 +448,8 @@ class MininetCLI(object):
self.nodemap = {} # map names to Node objects self.nodemap = {} # map names to Node objects
for node in self.mn.nodes.values(): for node in self.mn.nodes.values():
self.nodemap[node.name] = node 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.nodelist = self.nodemap.values()
self.run() self.run()
+8 -5
View File
@@ -253,13 +253,16 @@ class Switch(Node):
self.dp = datapath self.dp = datapath
Node.__init__(self, name, inNamespace = (datapath == None)) Node.__init__(self, name, inNamespace = (datapath == None))
def _startUserDatapath(self, controller): def _startUserDatapath(self, controllers):
'''Start OpenFlow reference user datapath. '''Start OpenFlow reference user datapath.
Log to /tmp/sN-{ofd,ofp}.log. 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' ofdlog = '/tmp/' + self.name + '-ofd.log'
ofplog = '/tmp/' + self.name + '-ofp.log' ofplog = '/tmp/' + self.name + '-ofp.log'
self.cmd('ifconfig lo up') self.cmd('ifconfig lo up')
@@ -302,13 +305,13 @@ class Switch(Node):
quietRun('ip link del ' + intf) quietRun('ip link del ' + intf)
lg.info('.') lg.info('.')
def start(self, controller): def start(self, controllers):
'''Start datapath. '''Start datapath.
@param controller Controller object @param controllers dict of controller names to objects
''' '''
if self.dp is None: if self.dp is None:
self._startUserDatapath(controller) self._startUserDatapath(controllers)
else: else:
self._startKernelDatapath() self._startKernelDatapath()