- container_cnt = len(self.containers)
- mod = container_cnt/dut_cnt
-
- for i, container in enumerate(self.containers):
- mid1 = i % mod + 1
- mid2 = i % mod + 1
- sid1 = i % mod * 2 + 1
- sid2 = i % mod * 2 + 2
- self.engine.container = self.containers[container]
- self.engine.create_vpp_startup_config()
- self.engine.create_vpp_exec_config(vat_template_file, mid1=mid1,
- mid2=mid2, sid1=sid1, sid2=sid2,
- socket1='memif-{c.name}-{sid}'
- .format(c=self.engine.container,
- sid=sid1),
- socket2='memif-{c.name}-{sid}'
- .format(c=self.engine.container,
- sid=sid2))
+ mod = len(self.containers)/dut_cnt
+ container_vat_template = 'memif_create_{topology}.vat'.format(
+ topology=chain_topology)
+
+ if chain_topology == 'chain':
+ for i, container in enumerate(self.containers):
+ mid1 = i % mod + 1
+ mid2 = i % mod + 1
+ sid1 = i % mod * 2 + 1
+ sid2 = i % mod * 2 + 2
+ self.engine.container = self.containers[container]
+ self.engine.create_vpp_startup_config()
+ self.engine.create_vpp_exec_config(container_vat_template, \
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2, \
+ socket1='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid1), \
+ socket2='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid2))
+ elif chain_topology == 'cross_horiz':
+ if mod > 1:
+ raise RuntimeError('Container chain topology {topology} '
+ 'supports only single container.'.
+ format(topology=chain_topology))
+ for i, container in enumerate(self.containers):
+ mid1 = i % mod + 1
+ sid1 = i % mod * 2 + 1
+ self.engine.container = self.containers[container]
+ if 'DUT1' in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr( \
+ self.engine.container.node, dut1_if)
+ if_name = Topology.get_interface_name( \
+ self.engine.container.node, dut1_if)
+ if 'DUT2' in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr( \
+ self.engine.container.node, dut2_if)
+ if_name = Topology.get_interface_name( \
+ self.engine.container.node, dut2_if)
+ self.engine.create_vpp_startup_config_dpdk_dev(if_pci)
+ self.engine.create_vpp_exec_config(container_vat_template, \
+ mid1=mid1, sid1=sid1, if_name=if_name, \
+ socket1='memif-{c.name}-{sid}'. \
+ format(c=self.engine.container, sid=sid1))
+ else:
+ raise RuntimeError('Container topology {topology} not implemented'.
+ format(topology=chain_topology))