Support for configuring/starting multiple switches in cord-tester.
Useful to fire tests with multiple switches configured with num_ports as per olt_config.json.
Change-Id: Ifbe65c75ad008db75ac5f4e3554e36499cb194de
diff --git a/src/test/utils/OltConfig.py b/src/test/utils/OltConfig.py
index 730b23d..acf2339 100644
--- a/src/test/utils/OltConfig.py
+++ b/src/test/utils/OltConfig.py
@@ -38,19 +38,57 @@
def olt_port_map(self):
if self.on_olt() and self.olt_conf.has_key('port_map'):
port_map = {}
+ if self.olt_conf['port_map'].has_key('switches'):
+ port_map['switches'] = self.olt_conf['port_map']['switches']
+ else:
+ port_map['switches'] = []
+ nr_switches = 1
+ if self.olt_conf['port_map'].has_key('nr_switches'):
+ nr_switches = int(self.olt_conf['port_map']['nr_switches'])
+ for sw in xrange(nr_switches):
+ switch = 'br-int{}'.format(sw+1) if sw > 0 else 'br-int'
+ port_map['switches'].append(switch)
+ #if we have a host interface enabled, invalidate the switches config
+ if self.olt_conf['port_map'].has_key('host'):
+ #if host interface is specified, then use the host instead of ovs switch
+ port_map['host'] = self.olt_conf['port_map']['host']
+ port_map['switches'] = [ port_map['host'] ]
+ else:
+ port_map['host'] = port_map['switches'][0]
+ nr_switches = len(port_map['switches'])
+ port_map['switch_port_list'] = []
if self.olt_conf['port_map'].has_key('ports'):
port_map['ports'] = self.olt_conf['port_map']['ports']
num_ports = len(port_map['ports'])
+ port_map['switch_port_list'].append( (port_map['switches'][0], port_map['ports']) )
else:
port_map['ports'] = []
num_ports = int(self.olt_conf['port_map']['num_ports'])
- for port in xrange(0, num_ports*2, 2):
- port_map['ports'].append('veth{}'.format(port))
+ for sw in xrange(nr_switches):
+ port_list = []
+ switch = port_map['switches'][sw]
+ port_start = sw * num_ports * 2
+ port_end = port_start + num_ports * 2
+ for port in xrange(port_start, port_end, 2):
+ port_name = 'veth{}'.format(port)
+ port_map['ports'].append(port_name)
+ port_list.append(port_name)
+ port_map['switch_port_list'].append( (switch, port_list) )
##also add dhcprelay ports. We add as many relay ports as subscriber ports
+ port_map['num_ports'] = num_ports
relay_ports = num_ports
port_map['relay_ports'] = []
- for port in xrange(relay_ports*2, relay_ports*4, 2):
- port_map['relay_ports'].append('veth{}'.format(port))
+ port_map['switch_relay_port_list'] = []
+ for sw in xrange(nr_switches):
+ port_list = []
+ switch = port_map['switches'][sw]
+ port_start = (nr_switches + sw) * relay_ports * 2
+ port_end = port_start + relay_ports * 2
+ for port in xrange(port_start, port_end, 2):
+ port_name = 'veth{}'.format(port)
+ port_map['relay_ports'].append(port_name)
+ port_list.append(port_name)
+ port_map['switch_relay_port_list'].append( (switch, port_list) )
port_num = 1
port_map['uplink'] = int(self.olt_conf['uplink'])
port_map['wan'] = None
@@ -58,23 +96,26 @@
port_map['wan'] = self.olt_conf['wan']
port_list = []
##build the port map and inverse port map
- for port in port_map['ports']:
- port_map[port_num] = port
- port_map[port] = port_num
- if port_num != port_map['uplink']:
- ##create tx,rx map
- port_list.append( (port_map['uplink'], port_num ) )
- port_num += 1
+ for sw in xrange(nr_switches):
+ sw_portnum = 1
+ switch, ports = port_map['switch_port_list'][sw]
+ uplink = sw * num_ports + port_map['uplink']
+ port_map[switch] = {}
+ port_map[switch]['uplink'] = uplink
+ for p in ports:
+ port_map[port_num] = p
+ port_map[p] = port_num
+ if sw_portnum != port_map['uplink']:
+ #create tx, rx map
+ port_list.append( (uplink, port_num) )
+ port_num += 1
+ sw_portnum += 1
##build the port and inverse map for relay ports
for port in port_map['relay_ports']:
port_map[port_num] = port
port_map[port] = port_num
port_num += 1
port_map['start_vlan'] = 0
- if self.olt_conf['port_map'].has_key('host'):
- port_map['host'] = self.olt_conf['port_map']['host']
- else:
- port_map['host'] = 'ovsbr0'
if self.olt_conf['port_map'].has_key('start_vlan'):
port_map['start_vlan'] = int(self.olt_conf['port_map']['start_vlan'])