Step 1: Move vm scripts to the right place
[integration/test.git] / csit / variables / ovsdb / ovsdb.py
1 """
2 Custom Topology to test extended Vxlan Tunnel Functionality created via OVSDB SouthBound plugin.
3 usage: mn --controller=remote,ip=<> --switch=ovsk,protocols=OpenFlow13 --custom <> --topo host1
4
5 """
6
7 from mininet.topo import Topo
8
9
10 def add_hosts(self, switch, hosts, start_host_suffix):
11     """Add and connect specified number of hosts to the the switch
12
13     Args:
14         :param switch: A string that describes the switch name to which the hosts are to be connected
15             example 's1 s2 s3 ...'
16
17         :param hosts: A integer that describes the number of hosts to be added to the switch
18
19         :param start_host_suffix: A integer that describes the starting suffix of the host from which
20
21     Returns:
22         :returns Nothing
23     """
24     host_suffix = start_host_suffix
25     for _ in range(hosts):
26         host = self.addHost("h%s" % host_suffix, ip="10.0.0.%s" % host_suffix)
27         self.addLink(switch, host)
28         host_suffix += 1
29
30
31 class HostTopo(Topo):
32     """Class to create a switch and host with suffix
33
34     Args:
35         :param host_suffix: specified else default is 1. For example: if equals to 3 (s3,h3)
36         :param hosts_per_switch: Number of hosts be connected to the switch. Default is 1.
37     """
38     def __init__(self, host_suffix=1, hosts_per_switch=1, **opts):
39         Topo.__init__(self, **opts)
40         switch = self.addSwitch('s%s' % host_suffix)
41         add_hosts(self, switch, hosts_per_switch, host_suffix)
42
43
44 topos = {'host': HostTopo}