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 <[email protected]>
---
 ryu/tests/switch/run_mininet.py |   27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/ryu/tests/switch/run_mininet.py b/ryu/tests/switch/run_mininet.py
index 40ef399..03bb91d 100755
--- a/ryu/tests/switch/run_mininet.py
+++ b/ryu/tests/switch/run_mininet.py
@@ -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)

-- 
1.7.10.4


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to