diff options
author | Peter Mikus <pmikus@cisco.com> | 2019-01-25 20:17:54 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2019-01-30 07:18:13 +0000 |
commit | 11bd03f27a53fa6060bfa72bc98c52532cb6e404 (patch) | |
tree | 1d6bc7798ac4321364565d46a4955b45aaf06f15 /resources/libraries/python/ContainerUtils.py | |
parent | e4293ce7243c222d0eb65b46bac2c3ba59dc7e5e (diff) |
CSIT-1409 Implement pipeline configuration for l2bd with memif/ip4.
Change-Id: I7463d47a9d65069332eb2a288ff44f4499a8a467
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/python/ContainerUtils.py')
-rw-r--r-- | resources/libraries/python/ContainerUtils.py | 208 |
1 files changed, 147 insertions, 61 deletions
diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 4feeb8bea2..8c299247e8 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -167,8 +167,6 @@ class ContainerManager(object): dut_cnt = len(Counter([self.containers[container].node['host'] for container in self.containers])) mod = len(self.containers)/dut_cnt - container_vat_template = 'memif_create_{topology}.vat'.format( - topology=chain_topology) for i, container in enumerate(self.containers): mid1 = i % mod + 1 @@ -179,69 +177,157 @@ class ContainerManager(object): guest_dir = self.engine.container.mnt[0].split(':')[1] if chain_topology == 'chain': - self.engine.create_vpp_startup_config() - self.engine.create_vpp_exec_config( - container_vat_template, - mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2, - socket1='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid1, dir=guest_dir), - socket2='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid2, dir=guest_dir)) + self._configure_vpp_chain_l2xc(mid1=mid1, mid2=mid2, + sid1=sid1, sid2=sid2, + guest_dir=guest_dir, + **kwargs) elif chain_topology == 'cross_horiz': - try: - dut1_if = kwargs['dut1_if'] - dut2_if = kwargs['dut2_if'] - except KeyError: - raise AttributeError('DUT interfaces not specified!') - 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='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid1, dir=guest_dir)) + self._configure_vpp_cross_horiz(mid1=mid1, mid2=mid2, + sid1=sid1, sid2=sid2, + guest_dir=guest_dir, + **kwargs) elif chain_topology == 'chain_functional': - memif_rx_mode = 'interrupt' - self.engine.create_vpp_startup_config_func_dev() - self.engine.create_vpp_exec_config( - container_vat_template, - mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2, - socket1='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid1, dir=guest_dir), - socket2='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid2, dir=guest_dir), - rx_mode=memif_rx_mode) + self._configure_vpp_chain_functional(mid1=mid1, mid2=mid2, + sid1=sid1, sid2=sid2, + guest_dir=guest_dir, + **kwargs) elif chain_topology == 'chain_ip4': - self.engine.create_vpp_startup_config() - vif1_mac = kwargs['tg_if1_mac'] \ - if (mid1 - 1) % kwargs['nodes'] + 1 == 1 \ - else '52:54:00:00:{0:02X}:02'.format(mid1-1) - vif2_mac = kwargs['tg_if2_mac'] \ - if (mid2 - 1) % kwargs['nodes'] + 1 == kwargs['nodes'] \ - else '52:54:00:00:{0:02X}:01'.format(mid2+1) - self.engine.create_vpp_exec_config( - container_vat_template, - mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2, - socket1='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid1, dir=guest_dir), - socket2='{dir}/memif-{c.name}-{sid}'. - format(c=self.engine.container, sid=sid2, dir=guest_dir), - mac1='52:54:00:00:{0:02X}:01'.format(mid1), - mac2='52:54:00:00:{0:02X}:02'.format(mid2), - vif1_mac=vif1_mac, vif2_mac=vif2_mac) + self._configure_vpp_chain_ip4(mid1=mid1, mid2=mid2, + sid1=sid1, sid2=sid2, + guest_dir=guest_dir, + **kwargs) + elif chain_topology == 'pipeline_ip4': + self._configure_vpp_pipeline_ip4(mid1=mid1, mid2=mid2, + sid1=sid1, sid2=sid2, + guest_dir=guest_dir, + **kwargs) else: - raise RuntimeError('Container topology {topology} not ' - 'implemented'. - format(topology=chain_topology)) + raise RuntimeError('Container topology {name} not implemented'. + format(name=chain_topology)) + + def _configure_vpp_chain_l2xc(self, **kwargs): + """Configure VPP in chain topology with l2xc. + + :param kwargs: Named parameters. + :param kwargs: dict + """ + self.engine.create_vpp_startup_config() + self.engine.create_vpp_exec_config( + 'memif_create_chain_l2xc.vat', + mid1=kwargs['mid1'], mid2=kwargs['mid2'], + sid1=kwargs['sid1'], sid2=kwargs['sid2'], + socket1='{guest_dir}/memif-{c.name}-{sid1}'. + format(c=self.engine.container, **kwargs), + socket2='{guest_dir}/memif-{c.name}-{sid2}'. + format(c=self.engine.container, **kwargs)) + + def _configure_vpp_cross_horiz(self, **kwargs): + """Configure VPP in cross horizontal topology (single memif). + + :param kwargs: Named parameters. + :param kwargs: dict + """ + if 'DUT1' in self.engine.container.name: + if_pci = Topology.get_interface_pci_addr( + self.engine.container.node, kwargs['dut1_if']) + if_name = Topology.get_interface_name( + self.engine.container.node, kwargs['dut1_if']) + if 'DUT2' in self.engine.container.name: + if_pci = Topology.get_interface_pci_addr( + self.engine.container.node, kwargs['dut2_if']) + if_name = Topology.get_interface_name( + self.engine.container.node, kwargs['dut2_if']) + self.engine.create_vpp_startup_config_dpdk_dev(if_pci) + self.engine.create_vpp_exec_config( + 'memif_create_cross_horizon.vat', + mid1=kwargs['mid1'], sid1=kwargs['sid1'], if_name=if_name, + socket1='{guest_dir}/memif-{c.name}-{sid1}'. + format(c=self.engine.container, **kwargs)) + + def _configure_vpp_chain_functional(self, **kwargs): + """Configure VPP in chain topology with l2xc (functional). + + :param kwargs: Named parameters. + :param kwargs: dict + """ + self.engine.create_vpp_startup_config_func_dev() + self.engine.create_vpp_exec_config( + 'memif_create_chain_functional.vat', + mid1=kwargs['mid1'], mid2=kwargs['mid2'], + sid1=kwargs['sid1'], sid2=kwargs['sid2'], + socket1='{guest_dir}/memif-{c.name}-{sid1}'. + format(c=self.engine.container, **kwargs), + socket2='{guest_dir}/memif-{c.name}-{sid2}'. + format(c=self.engine.container, **kwargs), + rx_mode='interrupt') + + def _configure_vpp_chain_ip4(self, **kwargs): + """Configure VPP in chain topology with ip4. + + :param kwargs: Named parameters. + :param kwargs: dict + """ + self.engine.create_vpp_startup_config() + + vif1_mac = kwargs['tg_if1_mac'] \ + if (kwargs['mid1'] - 1) % kwargs['nodes'] + 1 == 1 \ + else '52:54:00:00:{0:02X}:02'.format(kwargs['mid1'] - 1) + vif2_mac = kwargs['tg_if2_mac'] \ + if (kwargs['mid2'] - 1) % kwargs['nodes'] + 1 == kwargs['nodes'] \ + else '52:54:00:00:{0:02X}:01'.format(kwargs['mid2'] + 1) + self.engine.create_vpp_exec_config( + 'memif_create_chain_ip4.vat', + mid1=kwargs['mid1'], mid2=kwargs['mid2'], + sid1=kwargs['sid1'], sid2=kwargs['sid2'], + socket1='{guest_dir}/memif-{c.name}-{sid1}'. + format(c=self.engine.container, **kwargs), + socket2='{guest_dir}/memif-{c.name}-{sid2}'. + format(c=self.engine.container, **kwargs), + mac1='52:54:00:00:{0:02X}:01'.format(kwargs['mid1']), + mac2='52:54:00:00:{0:02X}:02'.format(kwargs['mid2']), + vif1_mac=vif1_mac, vif2_mac=vif2_mac) + + def _configure_vpp_pipeline_ip4(self, **kwargs): + """Configure VPP in pipeline topology with ip4. + + :param kwargs: Named parameters. + :param kwargs: dict + """ + self.engine.create_vpp_startup_config() + node = (kwargs['mid1'] - 1) % kwargs['nodes'] + 1 + mid1 = kwargs['mid1'] + mid2 = kwargs['mid2'] + role1 = 'master' + role2 = 'master' \ + if node == kwargs['nodes'] or node == kwargs['nodes'] and node == 1\ + else 'slave' + kwargs['mid2'] = kwargs['mid2'] \ + if node == kwargs['nodes'] or node == kwargs['nodes'] and node == 1\ + else kwargs['mid2'] + 1 + vif1_mac = kwargs['tg_if1_mac'] \ + if (kwargs['mid1'] - 1) % kwargs['nodes'] + 1 == 1 \ + else '52:54:00:00:{0:02X}:02'.format(kwargs['mid1'] - 1) + vif2_mac = kwargs['tg_if2_mac'] \ + if (kwargs['mid2'] - 1) % kwargs['nodes'] + 1 == kwargs['nodes'] \ + else '52:54:00:00:{0:02X}:01'.format(kwargs['mid2'] + 1) + socket1 = '{guest_dir}/memif-{c.name}-{sid1}'.\ + format(c=self.engine.container, **kwargs) \ + if node == 1 else '{guest_dir}/memif-pipe-{mid1}'.\ + format(c=self.engine.container, **kwargs) + socket2 = '{guest_dir}/memif-{c.name}-{sid2}'.\ + format(c=self.engine.container, **kwargs) \ + if node == 1 and kwargs['nodes'] == 1 or node == kwargs['nodes'] \ + else '{guest_dir}/memif-pipe-{mid2}'.\ + format(c=self.engine.container, **kwargs) + + self.engine.create_vpp_exec_config( + 'memif_create_pipeline_ip4.vat', + mid1=kwargs['mid1'], mid2=kwargs['mid2'], + sid1=kwargs['sid1'], sid2=kwargs['sid2'], + socket1=socket1, socket2=socket2, role1=role1, role2=role2, + mac1='52:54:00:00:{0:02X}:01'.format(mid1), + mac2='52:54:00:00:{0:02X}:02'.format(mid2), + vif1_mac=vif1_mac, vif2_mac=vif2_mac) def stop_all_containers(self): """Stop all containers.""" |