Revision c916f3ee mininet/link.py

View differences:

mininet/link.py
26 26

  
27 27
from mininet.log import info, error, debug
28 28
from mininet.util import makeIntfPair, quietRun
29
import mininet.node
29 30
import re
30 31

  
31 32
class Intf( object ):
......
453 454
    def __str__( self ):
454 455
        return '%s<->%s' % ( self.intf1, self.intf2 )
455 456

  
457

  
458
class OVSIntf( Intf ):
459
    "Patch interface on an OVSSwitch"
460

  
461
    def ifconfig( self, cmd ):
462
        if cmd == 'up':
463
            "OVSIntf is always up"
464
            return
465
        else:
466
            raise Exception( 'OVSIntf cannot do ifconfig ' + cmd )
467

  
468

  
469
class OVSLink( Link ):
470
    "Link that makes patch links between OVSSwitches"
471

  
472
    def __init__( self, node1, node2, **kwargs ):
473
        "See Link.__init__() for options"
474
        self.isPatchLink = False
475
        if ( type( node1 ) is mininet.node.OVSSwitch and
476
             type( node2 ) is mininet.node.OVSSwitch ):
477
             self.isPatchLink = True
478
             kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
479
        Link.__init__( self, node1, node2, **kwargs )
480

  
481
    def makeIntfPair( self, *args, **kwargs ):
482
        "Usually delegated to OVSSwitch"
483
        if self.isPatchLink:
484
            return None, None
485
        else:
486
            return Link.makeIntfPair( *args, **kwargs )
487

  
488

  
456 489
class TCLink( Link ):
457 490
    "Link with symmetric TC interfaces configured via opts"
458 491
    def __init__( self, node1, node2, port1=None, port2=None,

Also available in: Unified diff