Fixed issue with custom topology file.
authorAmit Mandke <ammandke@cisco.com>
Thu, 4 Sep 2014 00:16:38 +0000 (17:16 -0700)
committerAmit Mandke <ammandke@cisco.com>
Thu, 4 Sep 2014 00:16:38 +0000 (17:16 -0700)
The file was not being copied on mininet vm by the test. It
was expected to be present there. This fix would copy the file.
Also changed custom topology file to a newer script.

Change-Id: I1072c348ec8bc66e8cf5d7d1466019e869cbcdf6
Signed-off-by: Amit Mandke <ammandke@cisco.com>
test/csit/suites/l2switch/030__LoopRemoval_OF13/__init__.txt
test/csit/suites/l2switch/topologies/customtopo.py [new file with mode: 0755]
test/csit/suites/l2switch/topologies/loop.py [deleted file]

index d4d6eae73a4b057cb6af46e7ac3d4417a9f45dd6..645ae2f6725b34dc13a483d2b9514b65b4351f8f 100644 (file)
@@ -5,7 +5,7 @@ Suite Teardown    Stop Suite
 Library     SSHLibrary
 
 *** Variables ***
-${start}=  sudo mn --controller=remote,ip=${CONTROLLER} --custom ${USER_HOME}/integration/test/csit/suites/l2switch/topologies/loop.py --topo loop --switch ovsk,protocols=OpenFlow13
+${start}=  sudo mn --controller=remote,ip=${CONTROLLER} --custom customtopo.py --topo ring --switch ovsk,protocols=OpenFlow13
 
 ** Keywords ***
 Start Suite
@@ -15,6 +15,7 @@ Start Suite
     Write    sudo ovs-vsctl set-manager ptcp:6644
     Write    sudo mn -c
     Sleep    2
+    Put File    ${USER_HOME}/integration/test/csit/suites/l2switch/topologies/customtopo.py
     Write    ${start}
     Sleep    30
     Read
diff --git a/test/csit/suites/l2switch/topologies/customtopo.py b/test/csit/suites/l2switch/topologies/customtopo.py
new file mode 100755 (executable)
index 0000000..53327ad
--- /dev/null
@@ -0,0 +1,54 @@
+# !/usr/bin/python
+
+# usage: sudo mn --controller=remote,ip=<controller_ip> --switch=ovsk,protocols=OpenFlow13 --custom <path to customtopo.py> --topo ring ...
+
+from mininet.topo import Topo
+
+
+def add_hosts_to_switch(self, switch, hosts, start_host_suffix):
+    host_suffix = start_host_suffix
+    for _ in range(hosts):
+        host = self.addHost("h%s" % host_suffix)
+        self.addLink(switch, host)
+        host_suffix += 1
+
+
+class RingTopo(Topo):
+    def __init__(self, switches=3, hosts_per_switch=1, **opts):
+        Topo.__init__(self, **opts)
+        host_suffix = 1
+        switch = self.addSwitch('s%s' % 1)
+        first_switch = switch
+        for i in range(1, switches):
+            # add hosts to switch
+            add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
+            host_suffix += hosts_per_switch
+
+            new_switch = self.addSwitch('s%s' % (i + 1))
+            self.addLink(new_switch, switch)
+            switch = new_switch
+
+        add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
+        self.addLink(switch, first_switch)
+
+
+class MeshTopo(Topo):
+    def __init__(self, switches=3, hosts_per_switch=1, **opts):
+        Topo.__init__(self, **opts)
+        created_switches = []
+        host_suffix = 1
+        for i in range(switches):
+            new_switch = self.addSwitch('s%s' % (i + 1))
+
+            # add hosts to new switch
+            add_hosts_to_switch(self, new_switch, hosts_per_switch, host_suffix)
+            host_suffix += hosts_per_switch
+
+            for switch in created_switches:
+                self.addLink(new_switch, switch)
+
+            created_switches.append(new_switch)
+
+
+topos = {'ring': RingTopo,
+         'mesh': MeshTopo}
diff --git a/test/csit/suites/l2switch/topologies/loop.py b/test/csit/suites/l2switch/topologies/loop.py
deleted file mode 100644 (file)
index 45cea0a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-# usage: sudo mn --controller=remote,ip=<controller_ip> --switch=ovsk,protocols=OpenFlow13 --custom <path to createtopo.py> --topo loop ...
-
-from mininet.topo import Topo
-from mininet.net import Mininet
-from mininet.node import RemoteController
-from mininet.cli import CLI
-
-class LoopTopo(Topo):
-        def __init__(self, switches = 3, hosts_per = 1, **opts):
-            Topo.__init__(self, **opts)
-            sws = []
-            hnum = 0
-            for i in range(switches):
-                sw = self.addSwitch('s%s' % (i+ 1))
-
-                for _ in range(hosts_per):
-                    hnum += 1
-                    host = self.addHost('h%s' % hnum)
-                    self.addLink(sw, host)
-
-                for rhs in sws:
-                    self.addLink(sw, rhs)
-
-                sws.append(sw)
-
-topos = { 'loop': LoopTopo }