test tool: run_mininet: support CPqD Software Switch

this patch gets run_mininet.py to support CPqD Software Switch.

usage)

  to use CPqD Software Switch:
    sudo ryu/tests/switch/run_mininet.py --switch cpqd

  to use Open vSwitch:
    sudo ryu/tests/switch/run_mininet.py --switch ovs
      or
    sudo ryu/tests/switch/run_mininet.py

Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Yuichi Ito 2014-01-16 17:26:38 +09:00 committed by FUJITA Tomonori
parent dd70570eab
commit 31846f3f74

View File

@ -1,13 +1,33 @@
#!/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__:
net = Mininet(controller=RemoteController)
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')
@ -22,8 +42,9 @@ if '__main__' == __name__:
s1.start([c0])
s2.start([c0])
s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13')
s2.cmd('ovs-vsctl set Bridge s2 protocols=OpenFlow13')
if conf.switch == 'ovs':
s1.cmd('ovs-vsctl set Bridge s1 protocols=OpenFlow13')
s2.cmd('ovs-vsctl set Bridge s2 protocols=OpenFlow13')
CLI(net)