old_contents: #!/usr/bin/env python
  
  from mininet.cli import CLI
  from mininet.link import Link
  from mininet.net import Mininet
  from mininet.node import RemoteController
  from mininet.term import makeTerm
  
  if '__main__' == __name__:
      net = Mininet(controller=RemoteController)
  
      c0 = net.addController('c0')
  
      s1 = net.addSwitch('s1')
      s2 = net.addSwitch('s2')
  
      Link(s1, s2)
      Link(s1, s2)
  
      net.build()
      c0.start()
      s1.start([c0])
      s2.start([c0])
  
      s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13')
      s2.cmd('ovs-vsctl set Bridge s2 protocols=OpenFlow13')
  
      CLI(net)
  
      net.stop()
  
new_contents: #!/usr/bin/env python
  
  import sys
  
  from mininet.cli import CLI
  from mininet.link import Link
  from mininet.net import Mininet
  from mininet.node import RemoteController
  from mininet.node import OVSSwitch
  from mininet.node import UserSwitch
  from mininet.term import makeTerm
  
  from oslo.config import cfg
  from ryu import version
  
  if '__main__' == __name__:
  
      opts = [
          cfg.StrOpt('switch', default='ovs', help='test switch (ovs|cpqd)')
      ]
      conf = cfg.ConfigOpts()
      conf.register_cli_opts(opts)
      conf(project='ryu', version='run_mininet.py %s' % version)
      conf(sys.argv[1:])
      switch_type = {'ovs': OVSSwitch, 'cpqd': UserSwitch}
      switch = switch_type.get(conf.switch)
      if switch is None:
          raise ValueError('Invalid switch type. [%s]', conf.switch)
  
      net = Mininet(switch=switch, controller=RemoteController)
  
      c0 = net.addController('c0')
  
      s1 = net.addSwitch('s1')
      s2 = net.addSwitch('s2')
  
      Link(s1, s2)
      Link(s1, s2)
  
      net.build()
      c0.start()
      s1.start([c0])
      s2.start([c0])
  
      if conf.switch == 'ovs':
          s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13')
          s2.cmd('ovs-vsctl set Bridge s2 protocols=OpenFlow13')
  
      CLI(net)
  
      net.stop()
  
subject: test tool: run_mininet: support CPqD Software Switch