Revision 38ce329e mininet/net.py

View differences:

mininet/net.py
337 337
            paramDict: dictionary of additional link params (optional)
338 338
            params: additional link params (optional)
339 339
            returns: link object"""
340
        mac1 = self.randMac()
341
        mac2 = self.randMac()
342
        paramDict = {} if paramDict is None else paramDict
343
        paramDict.update( params )
344 340
        # Ugly: try to ensure that node1 and node2 line up correctly with
345
        # other link parameters
346
        node1 = self[ paramDict.pop( 'node1', node1.name ) ]
347
        node2 = self[ paramDict.pop( 'node2', node2.name ) ]
341
        # other link parameters, and allow either nodes or names
342
        paramDict = {} if paramDict is None else dict( paramDict )
343
        paramDict.update( params )
344
        node1 = paramDict.pop( 'node1', node1 )
345
        node2 = paramDict.pop( 'node2', node1 )
346
        node1 = node1 if type( node1 ) != str else self[ node1 ]
347
        node2 = node2 if type( node2 ) != str else self[ node2 ]
348 348
        paramDict.setdefault( 'port1', port1 )
349 349
        paramDict.setdefault( 'port2', port2 )
350
        paramDict.setdefault( 'addr1', mac1 )
351
        paramDict.setdefault( 'addr2', mac2 )
350
        paramDict.setdefault( 'addr1', self.randMac() )
351
        paramDict.setdefault( 'addr2', self.randMac() )
352 352
        cls = self.link if cls is None else cls
353 353
        link = cls( node1, node2, **paramDict )
354 354
        self.links.append( link )
......
408 408
            info( switchName + ' ' )
409 409

  
410 410
        info( '\n*** Adding links:\n' )
411
        for srcName, dstName in topo.links( sort=True ):
412
            src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ]
413
            params = topo.linkInfo( srcName, dstName )
414
            srcPort, dstPort = topo.port( srcName, dstName )
415
            self.addLink( src, dst, srcPort, dstPort, paramDict=params )
416
            info( '(%s, %s) ' % ( src.name, dst.name ) )
411
        for srcName, dstName, params in topo.links(
412
                sort=True, withInfo=True ):
413
            self.addLink( srcName, dstName, paramDict=params )
414
            info( '(%s, %s) ' % ( srcName, dstName ) )
417 415

  
418 416
        info( '\n' )
419 417

  

Also available in: Unified diff