Beispiel #1
0
    def create_kernelvm_config_vpp(self, **kwargs):
        """Create QEMU VPP config files.

        :param kwargs: Key-value pairs to replace content of VPP configuration
            file.
        :type kwargs: dict
        """
        startup = f"/etc/vpp/vm_startup_{self._opt.get(u'qemu_id')}.conf"
        running = f"/etc/vpp/vm_running_{self._opt.get(u'qemu_id')}.exec"

        self._temp[u"startup"] = startup
        self._temp[u"running"] = running
        self._opt[u"vnf_bin"] = f"/usr/bin/vpp -c {startup}"

        # Create VPP startup configuration.
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self._node)
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_exec(running)
        vpp_config.add_socksvr()
        vpp_config.add_main_heap_size(u"512M")
        vpp_config.add_main_heap_page_size(u"2M")
        vpp_config.add_statseg_size(u"512M")
        vpp_config.add_statseg_page_size(u"2M")
        vpp_config.add_statseg_per_node_counters(u"on")
        vpp_config.add_buffers_per_numa(107520)
        vpp_config.add_cpu_main_core(u"0")
        if self._opt.get(u"smp") > 1:
            vpp_config.add_cpu_corelist_workers(f"1-{self._opt.get(u'smp')-1}")
        vpp_config.add_plugin(u"disable", u"default")
        vpp_config.add_plugin(u"enable", u"ping_plugin.so")
        if "2vfpt" in self._opt.get(u'vnf'):
            vpp_config.add_plugin(u"enable", u"avf_plugin.so")
        if "vhost" in self._opt.get(u'vnf'):
            vpp_config.add_plugin(u"enable", u"dpdk_plugin.so")
            vpp_config.add_dpdk_dev(u"0000:00:06.0", u"0000:00:07.0")
            vpp_config.add_dpdk_dev_default_rxq(kwargs[u"queues"])
            vpp_config.add_dpdk_log_level(u"debug")
            if not kwargs[u"jumbo_frames"]:
                vpp_config.add_dpdk_no_multi_seg()
                vpp_config.add_dpdk_no_tx_checksum_offload()
        if "ipsec" in self._opt.get(u'vnf'):
            vpp_config.add_plugin(u"enable", u"crypto_native_plugin.so")
            vpp_config.add_plugin(u"enable", u"crypto_ipsecmb_plugin.so")
            vpp_config.add_plugin(u"enable", u"crypto_openssl_plugin.so")
        if "nat" in self._opt.get(u'vnf'):
            vpp_config.add_nat(value=u"endpoint-dependent")
            vpp_config.add_plugin(u"enable", u"nat_plugin.so")
        vpp_config.write_config(startup)

        # Create VPP running configuration.
        template = f"{Constants.RESOURCES_TPL}/vm/{self._opt.get(u'vnf')}.exec"
        exec_cmd_no_error(self._node, f"rm -f {running}", sudo=True)

        with open(template, u"rt") as src_file:
            src = Template(src_file.read())
            exec_cmd_no_error(
                self._node, f"echo '{src.safe_substitute(**kwargs)}' | "
                f"sudo tee {running}")
Beispiel #2
0
    def create_base_vpp_startup_config(self):
        """Create base startup configuration of VPP on container.

        :returns: Base VPP startup configuration.
        :rtype: VppConfigGenerator
        """
        cpuset_cpus = self.container.cpuset_cpus

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self.container.node)
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_exec('/tmp/running.exec')
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_cpus.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)

        return vpp_config
    def create_kubernetes_vnf_startup_config(**kwargs):
        """Create Kubernetes VNF startup configuration.

        :param kwargs: Key-value pairs used to create configuration.
        :param kwargs: dict
        """
        skip_cnt = kwargs['cpu_skip'] + (kwargs['i'] - 1) * \
            (kwargs['cpu_cnt'] - 1)
        cpuset_cpus = \
            CpuUtils.cpu_slice_of_list_per_node(node=kwargs['node'],
                                                cpu_node=kwargs['cpu_node'],
                                                skip_cnt=skip_cnt,
                                                cpu_cnt=kwargs['cpu_cnt']-1,
                                                smt_used=kwargs['smt_used'])
        cpuset_main = \
            CpuUtils.cpu_slice_of_list_per_node(node=kwargs['node'],
                                                cpu_node=kwargs['cpu_node'],
                                                skip_cnt=1,
                                                cpu_cnt=1,
                                                smt_used=kwargs['smt_used'])
        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(kwargs['node'])
        vpp_config.add_unix_cli_listen(value='0.0.0.0:5002')
        vpp_config.add_unix_nodaemon()
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_main.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.add_plugin_disable('dpdk_plugin.so')
        vpp_config.apply_config(filename=kwargs['filename'], restart_vpp=False)
Beispiel #4
0
    def create_kernelvm_config_vpp(self, **kwargs):
        """Create QEMU VPP config files.

        :param kwargs: Key-value pairs to replace content of VPP configuration
            file.
        :type kwargs: dict
        """
        startup = ('/etc/vpp/vm_startup_{id}.conf'.
                   format(id=self._opt.get('qemu_id')))
        running = ('/etc/vpp/vm_running_{id}.exec'.
                   format(id=self._opt.get('qemu_id')))

        self._temp['startup'] = startup
        self._temp['running'] = running
        self._opt['vnf_bin'] = ('/usr/bin/vpp -c {startup}'.
                                format(startup=startup))

        # Create VPP startup configuration.
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self._node)
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_exec(running)
        vpp_config.add_cpu_main_core('0')
        vpp_config.add_cpu_corelist_workers('1-{smp}'.
                                            format(smp=self._opt.get('smp')-1))
        vpp_config.add_dpdk_dev('0000:00:06.0', '0000:00:07.0')
        vpp_config.add_dpdk_dev_default_rxq(kwargs['queues'])
        vpp_config.add_dpdk_log_level('debug')
        if not kwargs['jumbo_frames']:
            vpp_config.add_dpdk_no_multi_seg()
            vpp_config.add_dpdk_no_tx_checksum_offload()
        vpp_config.add_plugin('disable', 'default')
        vpp_config.add_plugin('enable', 'dpdk_plugin.so')
        vpp_config.write_config(startup)

        # Create VPP running configuration.
        template = '{res}/{tpl}.exec'.format(res=Constants.RESOURCES_TPL_VM,
                                             tpl=self._opt.get('vnf'))
        exec_cmd_no_error(self._node, 'rm -f {running}'.format(running=running),
                          sudo=True)

        with open(template, 'r') as src_file:
            src = Template(src_file.read())
            exec_cmd_no_error(
                self._node, "echo '{out}' | sudo tee {running}".format(
                    out=src.safe_substitute(**kwargs), running=running))
Beispiel #5
0
    def create_base_vpp_startup_config(self, cpuset_cpus=None):
        """Create base startup configuration of VPP on container.

        :param cpuset_cpus: List of CPU cores to allocate.
        :type cpuset_cpus: list.
        :returns: Base VPP startup configuration.
        :rtype: VppConfigGenerator
        """
        if cpuset_cpus is None:
            cpuset_cpus = self.container.cpuset_cpus

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self.container.node)
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_exec(u"/tmp/running.exec")
        vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH)
        vpp_config.add_statseg_per_node_counters(value=u"on")
        if cpuset_cpus:
            # We will pop the first core from the list to be a main core
            vpp_config.add_cpu_main_core(str(cpuset_cpus.pop(0)))
            # If more cores in the list, the rest will be used as workers.
            corelist_workers = u",".join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.add_buffers_per_numa(215040)
        vpp_config.add_plugin(u"disable", u"default")
        vpp_config.add_plugin(u"enable", u"memif_plugin.so")
        vpp_config.add_heapsize(u"4G")
        vpp_config.add_ip_heap_size(u"4G")
        vpp_config.add_statseg_size(u"4G")

        return vpp_config
    def create_kubernetes_vswitch_startup_config(**kwargs):
        """Create Kubernetes VSWITCH startup configuration.

        :param kwargs: Key-value pairs used to create configuration.
        :param kwargs: dict
        """
        cpuset_cpus = \
            CpuUtils.cpu_slice_of_list_per_node(node=kwargs['node'],
                                                cpu_node=kwargs['cpu_node'],
                                                skip_cnt=kwargs['cpu_skip'],
                                                cpu_cnt=kwargs['cpu_cnt'],
                                                smt_used=kwargs['smt_used'])

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(kwargs['node'])
        vpp_config.add_unix_cli_listen(value='0.0.0.0:5002')
        vpp_config.add_unix_nodaemon()
        vpp_config.add_dpdk_socketmem('1024,1024')
        vpp_config.add_heapsize('3G')
        vpp_config.add_ip6_hash_buckets('2000000')
        vpp_config.add_ip6_heap_size('3G')
        if kwargs['framesize'] < 1522:
            vpp_config.add_dpdk_no_multi_seg()
        vpp_config.add_dpdk_dev_default_rxq(kwargs['rxq'])
        vpp_config.add_dpdk_dev(kwargs['if1'], kwargs['if2'])
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_cpus.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.apply_config(filename=kwargs['filename'], restart_vpp=False)
Beispiel #7
0
    def create_kubernetes_vswitch_startup_config(**kwargs):
        """Create Kubernetes VSWITCH startup configuration.

        :param kwargs: Key-value pairs used to create configuration.
        :param kwargs: dict
        """
        smt_used = CpuUtils.is_smt_enabled(kwargs['node']['cpuinfo'])

        cpuset_cpus = \
            CpuUtils.cpu_slice_of_list_per_node(node=kwargs['node'],
                                                cpu_node=kwargs['cpu_node'],
                                                skip_cnt=2,
                                                cpu_cnt=kwargs['phy_cores'],
                                                smt_used=smt_used)
        cpuset_main = \
            CpuUtils.cpu_slice_of_list_per_node(node=kwargs['node'],
                                                cpu_node=kwargs['cpu_node'],
                                                skip_cnt=1,
                                                cpu_cnt=1,
                                                smt_used=smt_used)

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(kwargs['node'])
        vpp_config.add_unix_cli_listen(value='0.0.0.0:5002')
        vpp_config.add_unix_nodaemon()
        vpp_config.add_heapsize('4G')
        vpp_config.add_ip_heap_size('4G')
        vpp_config.add_ip6_heap_size('4G')
        vpp_config.add_ip6_hash_buckets('2000000')
        if not kwargs['jumbo']:
            vpp_config.add_dpdk_no_multi_seg()
        vpp_config.add_dpdk_no_tx_checksum_offload()
        vpp_config.add_dpdk_dev_default_rxq(kwargs['rxq_count_int'])
        vpp_config.add_dpdk_dev(kwargs['if1'], kwargs['if2'])
        vpp_config.add_buffers_per_numa(kwargs['buffers_per_numa'])
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_main.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.write_config(filename=kwargs['filename'])
Beispiel #8
0
    def create_kubernetes_vnf_startup_config(**kwargs):
        """Create Kubernetes VNF startup configuration.

        :param kwargs: Key-value pairs used to create configuration.
        :param kwargs: dict
        """
        smt_used = CpuUtils.is_smt_enabled(kwargs[u"node"][u"cpuinfo"])
        skip_cnt = kwargs[u"cpu_skip"] + (kwargs[u"i"] - 1) * \
            (kwargs[u"phy_cores"] - 1)
        cpuset_cpus = CpuUtils.cpu_slice_of_list_per_node(
            node=kwargs[u"node"],
            cpu_node=kwargs[u"cpu_node"],
            skip_cnt=skip_cnt,
            cpu_cnt=kwargs[u"phy_cores"] - 1,
            smt_used=smt_used)
        cpuset_main = CpuUtils.cpu_slice_of_list_per_node(
            node=kwargs[u"node"],
            cpu_node=kwargs[u"cpu_node"],
            skip_cnt=1,
            cpu_cnt=1,
            smt_used=smt_used)
        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(kwargs[u"node"])
        vpp_config.add_unix_cli_listen(value=u"0.0.0.0:5002")
        vpp_config.add_unix_nodaemon()
        vpp_config.add_socksvr()
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_main.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = u",".join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.add_plugin(u"disable", [u"dpdk_plugin.so"])
        vpp_config.write_config(filename=kwargs[u"filename"])
    def create_vpp_startup_config(self,
                                  config_filename='/etc/vpp/startup.conf'):
        """Create base startup configuration of VPP on container.

        :param config_filename: Startup configuration file name.
        :type config_filename: str
        """
        cpuset_cpus = self.container.cpuset_cpus

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self.container.node)
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_exec('/tmp/running.exec')
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_cpus.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.add_plugin_disable('dpdk_plugin.so')

        self.execute('mkdir -p /etc/vpp/')
        self.execute('echo "{c}" | tee {f}'.format(
            c=vpp_config.get_config_str(), f=config_filename))
Beispiel #10
0
    def create_vpp_startup_config_func_dev(self):
        """Create startup configuration of VPP on container for functional
        vpp_device tests.
        """
        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(self.container.node)
        vpp_config.add_unix_cli_listen()
        vpp_config.add_unix_nodaemon()
        vpp_config.add_unix_exec('/tmp/running.exec')
        vpp_config.add_plugin('disable', 'dpdk_plugin.so')

        # Apply configuration
        self.execute('mkdir -p /etc/vpp/')
        self.execute('echo "{config}" | tee /etc/vpp/startup.conf'
                     .format(config=vpp_config.get_config_str()))
Beispiel #11
0
    def create_kubernetes_vswitch_startup_config(**kwargs):
        """Create Kubernetes VSWITCH startup configuration.

        :param kwargs: Key-value pairs used to create configuration.
        :param kwargs: dict
        """
        smt_used = CpuUtils.is_smt_enabled(kwargs[u"node"][u"cpuinfo"])

        cpuset_cpus = CpuUtils.cpu_slice_of_list_per_node(
            node=kwargs[u"node"],
            cpu_node=kwargs[u"cpu_node"],
            skip_cnt=2,
            cpu_cnt=kwargs[u"phy_cores"],
            smt_used=smt_used)
        cpuset_main = CpuUtils.cpu_slice_of_list_per_node(
            node=kwargs[u"node"],
            cpu_node=kwargs[u"cpu_node"],
            skip_cnt=1,
            cpu_cnt=1,
            smt_used=smt_used)

        # Create config instance
        vpp_config = VppConfigGenerator()
        vpp_config.set_node(kwargs[u"node"])
        vpp_config.add_unix_cli_listen(value=u"0.0.0.0:5002")
        vpp_config.add_unix_nodaemon()
        vpp_config.add_socksvr()
        vpp_config.add_ip6_heap_size(u"4G")
        vpp_config.add_ip6_hash_buckets(u"2000000")
        if not kwargs[u"jumbo"]:
            vpp_config.add_dpdk_no_multi_seg()
        vpp_config.add_dpdk_no_tx_checksum_offload()
        vpp_config.add_dpdk_dev_default_rxq(kwargs[u"rxq_count_int"])
        vpp_config.add_dpdk_dev(kwargs[u"if1"], kwargs[u"if2"])
        vpp_config.add_buffers_per_numa(kwargs[u"buffers_per_numa"])
        # We will pop first core from list to be main core
        vpp_config.add_cpu_main_core(str(cpuset_main.pop(0)))
        # if this is not only core in list, the rest will be used as workers.
        if cpuset_cpus:
            corelist_workers = u",".join(str(cpu) for cpu in cpuset_cpus)
            vpp_config.add_cpu_corelist_workers(corelist_workers)
        vpp_config.write_config(filename=kwargs[u"filename"])