Passing a Custom Switch class to Mininet topology
Question: This is a topology file for a popular network simulator called mininet

I have created a class MultiSwitch() below which I want to be passed to my
Topology class to be used as the default switch is there a way to do that? I
am not very proficient in Python

    
    
    from mininet.topo import Topo
    from mininet.node import OVSSwitch, Controller, RemoteController
    
    # Two "external" controllers 
    c0 = RemoteController( 'c1', ip='192.168.81.132')
    c1 = RemoteController( 'c2', ip='192.168.81.130')
    
    cmap = { 's1': c0, 's2': c0, 's3': c1,'s4':c1 }
    
    class MultiSwitch( OVSSwitch ):
        def start( self, controllers ):
            return OVSSwitch.start( self, [ cmap[ self.name ] ] )
    
    class OnosTopo( Topo ):
    
        "Simple topology example."
        def __init__( self ):
    
            "Create custom topo."
            # Initialize topology
    
            Topo.__init__( self )
    
            # Add hosts and switches
            h1 =  [ self.addHost( 'h1')]
            h2 =  [ self.addHost( 'h2')]
            h3 =  [ self.addHost( 'h3')]
            h4 =  [ self.addHost( 'h4')]
    
        s1 = [ self.addSwitch( 's1', dpid="0000000000000201")]
        s2 = [ self.addSwitch( 's2', dpid="0000000000000202")]
        s3 = [ self.addSwitch( 's3', dpid="0000000000000203")]
        s4 = [ self.addSwitch( 's4', dpid="0000000000000204")]
    
        #host to switch links
        self.addLink('s1','h1')
        self.addLink('s2','h2')
        self.addLink('s3','h3')
        self.addLink('s4','h4')
    
    
        #switch to swtich links
        self.addLink('s1','s2')
        self.addLink('s3','s4')
    
    topos = { 'onostopo': ( lambda: OnosTopo() ) }
    


Answer: the mininet.topo.py defines a method called as add_switch(),may be you can try
over-writting the add_switch() method with a custom add_switch() which adds
your custom switch in your custom topology, so whenever you run your topology,
the add_switch() method would create the custom switch .

