Revision 54037995 mininet/node.py

View differences:

mininet/node.py
292 292

  
293 293
class KernelSwitch(Switch):
294 294

  
295
    def __init__(self, name, datapath = None):
295
    def __init__(self, name, dp = None, dpid = None):
296 296
        '''Init.
297 297

  
298 298
        @param name
299
        @param datapath string, datapath name
299
        @param dp netlink id (0, 1, 2, ...)
300
        @param dpid datapath ID as unsigned int; random value if None
300 301
        '''
301
        self.dp = datapath
302
        Node.__init__(self, name, inNamespace = (datapath == None))
302
        Node.__init__(self, name, inNamespace = False)
303
        self.dp = dp
304
        self.dpid = dpid
303 305

  
304 306
    def start(self, ignore):
305 307
        '''Start up reference kernel datapath.'''
......
307 309
        quietRun('ifconfig lo up')
308 310
        # Delete local datapath if it exists;
309 311
        # then create a new one monitoring the given interfaces
310
        quietRun('dpctl deldp ' + self.dp)
311
        self.cmdPrint('dpctl adddp ' + self.dp)
312
        self.cmdPrint('dpctl addif ' + self.dp + ' ' + ' '.join(self.intfs))
312
        quietRun('dpctl deldp nl:%i' % self.dp)
313
        self.cmdPrint('dpctl adddp nl:%i' % self.dp)
314
        if self.dpid:
315
            intf = 'of%i' % self.dp
316
            mac_str = macColonHex(self.dpid)
317
            self.cmd(['ifconfig', intf, 'hw', 'ether', mac_str])
318
        self.cmdPrint('dpctl addif nl:' + str(self.dp) + ' ' +
319
                      ' '.join(self.intfs))
313 320
        # Run protocol daemon
314
        self.cmdPrint('ofprotocol' +
315
                      ' ' + self.dp + ' tcp:127.0.0.1 ' +
321
        self.cmdPrint('ofprotocol nl:' + str(self.dp) + ' tcp:127.0.0.1 ' +
316 322
                      ' --fail=closed 1> ' + ofplog + ' 2>' + ofplog + ' &')
317 323
        self.execed = False # XXX until I fix it
318 324

  
319 325
    def stop(self):
320 326
        '''Terminate reference kernel datapath.'''
321
        quietRun('dpctl deldp ' + self.dp)
327
        quietRun('dpctl deldp nl:%i' % self.dp)
322 328
        # In theory the interfaces should go away after we shut down.
323 329
        # However, this takes time, so we're better off to remove them
324 330
        # explicitly so that we won't get errors if we run before they

Also available in: Unified diff