X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVppConfigGenerator.py;h=d6afd1f5c758b30c09e7ec582d98b69b7c3650cf;hp=24fb8ce86f9905b407fdfdba2e578249afdeff94;hb=5e163c527fbb27900a4001226be70b98b271911a;hpb=dc1db8f3e4eb967cfce635ba8ff06a0cf4df5390 diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py index 24fb8ce86f..d6afd1f5c7 100644 --- a/resources/libraries/python/VppConfigGenerator.py +++ b/resources/libraries/python/VppConfigGenerator.py @@ -58,7 +58,14 @@ dpdk {{ }} {pciconfig} {nomultiseg} +{enablevhostuser} }} + +ip6 {{ + hash-buckets 2000000 + heap-size 3G +}} + """ # End VPP configuration template. @@ -209,6 +216,25 @@ class VppConfigGenerator(object): logger.debug('Setting hostname {} config with {}'.\ format(hostname, "no-multi-seg")) + def add_enable_vhost_user_config(self, node): + """Add enable-vhost-user configuration for node. + + :param node: DUT node. + :type node: dict + :return: nothing + """ + if node['type'] != NodeType.DUT: + raise ValueError('Node type is not a DUT') + hostname = Topology.get_node_hostname(node) + if not hostname in self._nodeconfig: + self._nodeconfig[hostname] = {} + if not 'enable_vhost_user' in self._nodeconfig[hostname]: + self._nodeconfig[hostname]['enable_vhost_user'] = [] + self._nodeconfig[hostname]['enable_vhost_user'].append( + "enable-vhost-user") + logger.debug('Setting hostname {} config with {}'.\ + format(hostname, "enable-vhost-user")) + def remove_all_pci_devices(self, node): """Remove PCI device configuration from node. @@ -299,6 +325,21 @@ class VppConfigGenerator(object): logger.debug('Clearing No Multi Seg config for hostname {}.'.\ format(hostname)) + def remove_enable_vhost_user_config(self, node): + """Remove enable-vhost-user configuration from node. + + :param node: DUT node. + :type node: dict + :return: nothing + """ + if node['type'] != NodeType.DUT: + raise ValueError('Node type is not a DUT') + hostname = Topology.get_node_hostname(node) + if hostname in self._nodeconfig: + self._nodeconfig[hostname]['enable_vhost_user'] = [] + logger.debug('Clearing enable-vhost-user config for hostname {}.'.\ + format(hostname)) + def apply_config(self, node, waittime=5, retries=12): """Generate and apply VPP configuration for node. @@ -324,6 +365,7 @@ class VppConfigGenerator(object): rxqueuesconfig = "" txqueuesconfig = "" nomultiseg = "" + enablevhostuser = "" if hostname in self._nodeconfig: cfg = self._nodeconfig[hostname] @@ -346,13 +388,17 @@ class VppConfigGenerator(object): if 'no_multi_seg_config' in cfg: nomultiseg = " " + "\n ".join(cfg['no_multi_seg_config']) + if 'enable_vhost_user' in cfg: + enablevhostuser = " " + "\n ".join(cfg['enable_vhost_user']) + vppconfig = VPP_CONFIG_TEMPLATE.format(cpuconfig=cpuconfig, pciconfig=pciconfig, socketmemconfig=socketmemconfig, heapsizeconfig=heapsizeconfig, rxqueuesconfig=rxqueuesconfig, txqueuesconfig=txqueuesconfig, - nomultiseg = nomultiseg) + nomultiseg=nomultiseg, + enablevhostuser=enablevhostuser) logger.debug('Writing VPP config to host {}: "{}"'.format(hostname, vppconfig)) @@ -378,9 +424,9 @@ class VppConfigGenerator(object): # Instead of restarting, we'll do separate start and stop # actions. This way we don't care whether VPP was running # to begin with. - ssh.exec_command('sudo initctl stop {}'.format(VPP_SERVICE_NAME)) + ssh.exec_command('sudo service {} stop'.format(VPP_SERVICE_NAME)) (ret, stdout, stderr) = \ - ssh.exec_command('sudo initctl start {}'.format(VPP_SERVICE_NAME)) + ssh.exec_command('sudo service {} start'.format(VPP_SERVICE_NAME)) if ret != 0: logger.debug('Restarting VPP failed on node {}'. format(hostname))