Merge "removing failing tests"
[integration/test.git] / test / csit / suites / karaf-l2switch / topologies / customtopo.py
1 # !/usr/bin/python
2
3 # usage: sudo mn --controller=remote,ip=<controller_ip> --switch=ovsk,protocols=OpenFlow13 --custom <path to customtopo.py> --topo ring ...
4
5 from mininet.topo import Topo
6
7
8 def add_hosts_to_switch(self, switch, hosts, start_host_suffix):
9     host_suffix = start_host_suffix
10     for _ in range(hosts):
11         host = self.addHost("h%s" % host_suffix)
12         self.addLink(switch, host)
13         host_suffix += 1
14
15
16 class RingTopo(Topo):
17     def __init__(self, switches=3, hosts_per_switch=1, **opts):
18         Topo.__init__(self, **opts)
19         host_suffix = 1
20         switch = self.addSwitch('s%s' % 1)
21         first_switch = switch
22         for i in range(1, switches):
23             # add hosts to switch
24             add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
25             host_suffix += hosts_per_switch
26
27             new_switch = self.addSwitch('s%s' % (i + 1))
28             self.addLink(new_switch, switch)
29             switch = new_switch
30
31         add_hosts_to_switch(self, switch, hosts_per_switch, host_suffix)
32         self.addLink(switch, first_switch)
33
34
35 class MeshTopo(Topo):
36     def __init__(self, switches=3, hosts_per_switch=1, **opts):
37         Topo.__init__(self, **opts)
38         created_switches = []
39         host_suffix = 1
40         for i in range(switches):
41             new_switch = self.addSwitch('s%s' % (i + 1))
42
43             # add hosts to new switch
44             add_hosts_to_switch(self, new_switch, hosts_per_switch, host_suffix)
45             host_suffix += hosts_per_switch
46
47             for switch in created_switches:
48                 self.addLink(new_switch, switch)
49
50             created_switches.append(new_switch)
51
52
53 topos = {'ring': RingTopo,
54          'mesh': MeshTopo}