aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2017-03-13 13:22:08 +0100
committerTibor Frank <tifrank@cisco.com>2017-04-18 11:24:44 +0200
commit28bab4e715a123199972bdc5f79f6a508a879fd6 (patch)
tree0b6c3a3aa71eb80143eae2c62086a61e153818c6 /resources/libraries/python
parent4da982b7a0f5872de2cc721607894216a20892f4 (diff)
CSIT-545: Performance tests for SNAT
- High level definition (HLD) - Low level definition (LLD) - Add keywords to set SNAT - Add tests according to HLD, LLD Change-Id: I7bf0b1870ac9c3adb36bb6590be9a3eb4ea8aa9a Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/SNATUtil.py171
-rw-r--r--resources/libraries/python/TrafficGenerator.py155
-rw-r--r--resources/libraries/python/VppConfigGenerator.py122
-rw-r--r--resources/libraries/python/ssh.py2
4 files changed, 407 insertions, 43 deletions
diff --git a/resources/libraries/python/SNATUtil.py b/resources/libraries/python/SNATUtil.py
new file mode 100644
index 0000000000..02cf493a93
--- /dev/null
+++ b/resources/libraries/python/SNATUtil.py
@@ -0,0 +1,171 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""SNAT utilities library."""
+
+from resources.libraries.python.VatExecutor import VatTerminal
+
+
+class SNATUtil(object):
+ """This class defines the methods to set SNAT."""
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def set_snat_interfaces(node, int_in, int_out):
+ """Set inside and outside interfaces for SNAT.
+
+ :param node: DUT node.
+ :param int_in: Inside interface.
+ :param int_out: Outside interface.
+ :type node: dict
+ :type int_in: str
+ :type int_out: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of inside and outside interfaces for
+ SNAT fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_interfaces.vat',
+ int_in=int_in, int_out=int_out)
+ return response
+ except:
+ raise RuntimeError("Setting of inside and outside interfaces for "
+ "SNAT failed!")
+
+ @staticmethod
+ def set_snat_deterministic(node, ip_in, subnet_in, ip_out, subnet_out):
+ """Set deterministic behaviour of SNAT.
+
+ :param node: DUT node.
+ :param ip_in: Inside IP.
+ :param subnet_in: Inside IP subnet.
+ :param ip_out: Outside IP.
+ :param subnet_out: Outside IP subnet.
+ :type node: dict
+ :type ip_in: str
+ :type subnet_in: str or int
+ :type ip_out: str
+ :type subnet_out: str or int
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of deterministic behaviour of SNAT
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_deterministic.vat',
+ ip_in=ip_in, subnet_in=subnet_in,
+ ip_out=ip_out, subnet_out=subnet_out)
+ return response
+ except:
+ raise RuntimeError("Setting of deterministic behaviour of SNAT "
+ "failed!")
+
+ @staticmethod
+ def set_snat_workers(node, lcores):
+ """Set SNAT workers.
+
+ :param node: DUT node.
+ :param lcores: list of cores, format: range e.g. 1-5 or list of ranges
+ e.g.: 1-5,18-22.
+ :type node: dict
+ :type lcores: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If setting of SNAT workers fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_set_workers.vat', lcores=lcores)
+ return response
+ except:
+ raise RuntimeError("Setting of SNAT workers failed!")
+
+ @staticmethod
+ def show_snat(node):
+ """Show the SNAT settings.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If getting of SNAT settings fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_show_snat.vat')
+ return response
+ except:
+ raise RuntimeError("Getting of SNAT settings failed!")
+
+ @staticmethod
+ def show_snat_deterministic_forward(node, ip_addr):
+ """Show forward IP address and port(s).
+
+ :param node: DUT node.
+ :param ip_addr: IP address.
+ :type node: dict
+ :type ip_addr: str
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If command 'exec snat deterministic forward'
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_deterministic_forward.vat', ip=ip_addr)
+ return response
+ except:
+ raise RuntimeError("Command 'exec snat deterministic forward {ip}'"
+ " failed!".format(ip=ip_addr))
+
+ @staticmethod
+ def show_snat_deterministic_reverse(node, ip_addr, port):
+ """Show reverse IP address.
+
+ :param node: DUT node.
+ :param ip_addr: IP address.
+ :param port: Port.
+ :type node: dict
+ :type ip_addr: str
+ :type port: str or int
+ :returns: Response of the command.
+ :rtype: str
+ :raises RuntimeError: If command 'exec snat deterministic reverse'
+ fails.
+ """
+
+ try:
+ with VatTerminal(node, json_param=False) as vat:
+ response = vat.vat_terminal_exec_cmd_from_template(
+ 'snat/snat_deterministic_reverse.vat',
+ ip=ip_addr, port=port)
+ return response
+ except:
+ raise RuntimeError(
+ "Command 'exec snat deterministic reverse {ip}:{port}'"
+ " failed!".format(ip=ip_addr, port=port))
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 2313ec856b..8387ce2b3c 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -438,6 +438,161 @@ class TrafficGenerator(object):
_p0, _p1, _async, _latency,
warmup_time),
timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1u-1p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.0 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1024 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1028 "
+ "--p{5}_dst_end_udp_port 1028 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.0 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 1038 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-10u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.9 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 1173 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-100u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.0.99 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 2523 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration) + 60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-1000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.3.231 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 16023 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-2000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.7.207 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 31022 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
+ elif traffic_type in ["3-node-IPv4-SNAT-4000u-15p"]:
+ (ret, stdout, stderr) = ssh.exec_command(
+ "sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
+ "--duration={1} -r {2} -s {3} "
+ "--p{4}_src_start_ip 20.0.0.0 "
+ "--p{4}_src_end_ip 20.0.15.159 "
+ "--p{4}_dst_start_ip 12.0.0.2 "
+ "--p{5}_src_start_ip 12.0.0.2 "
+ "--p{5}_src_end_ip 12.0.0.2 "
+ "--p{5}_dst_start_ip 200.0.0.0 "
+ "--p{4}_src_start_udp_port 1024 "
+ "--p{4}_src_end_udp_port 1038 "
+ "--p{4}_dst_start_udp_port 1024 "
+ "--p{5}_src_start_udp_port 1024 "
+ "--p{5}_dst_start_udp_port 1024 "
+ "--p{5}_dst_end_udp_port 61022 "
+ "{6} {7} --warmup_time={8}'".format(Constants.REMOTE_FW_DIR,
+ duration, rate, framesize,
+ _p0, _p1, _async, _latency,
+ warmup_time),
+ timeout=int(duration)+60)
+
elif traffic_type in ["3-node-IPv4-dst-10000"]:
(ret, stdout, stderr) = ssh.exec_command(
"sh -c '{0}/resources/tools/t-rex/t-rex-stateless.py "
diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py
index 267c47845f..e109d768fa 100644
--- a/resources/libraries/python/VppConfigGenerator.py
+++ b/resources/libraries/python/VppConfigGenerator.py
@@ -67,7 +67,7 @@ ip6 {{
hash-buckets 2000000
heap-size 3G
}}
-
+{snatconfig}
"""
# End VPP configuration template.
@@ -83,22 +83,21 @@ class VppConfigGenerator(object):
:param node: DUT node
:type node: dict
- :return: nothing
+ :returns: nothing
"""
for port in node['interfaces'].keys():
pci_addr = Topology.get_interface_pci_addr(node, port)
if pci_addr:
self.add_pci_device(node, pci_addr)
-
def add_pci_device(self, node, *pci_devices):
"""Add PCI device configuration for node.
:param node: DUT node.
- :param pci_device: PCI devices (format 0000:00:00.0 or 00:00.0)
+ :param pci_devices: PCI devices (format 0000:00:00.0 or 00:00.0)
:type node: dict
:type pci_devices: tuple
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -129,7 +128,7 @@ class VppConfigGenerator(object):
:param cpu_config: CPU configuration option, as a string.
:type node: dict
:type cpu_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -150,7 +149,7 @@ class VppConfigGenerator(object):
as a string.
:type node: dict
:type socketmem_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -168,7 +167,7 @@ class VppConfigGenerator(object):
:param heapsize_config: Heap Size configuration, as a string.
:type node: dict
:type heapsize_config: str
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -186,56 +185,73 @@ class VppConfigGenerator(object):
:param rxqueues_config: Rxqueues configuration, as a string.
:type node: dict
:type rxqueues_config: str
- :return: nothing
+ :returns: 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:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'rxqueues_config' in self._nodeconfig[hostname]:
+ if 'rxqueues_config' not in self._nodeconfig[hostname]:
self._nodeconfig[hostname]['rxqueues_config'] = []
self._nodeconfig[hostname]['rxqueues_config'].append(rxqueues_config)
- logger.debug('Setting hostname {} rxqueues config to {}'.\
- format(hostname, rxqueues_config))
+ logger.debug('Setting hostname {} rxqueues config to {}'.
+ format(hostname, rxqueues_config))
def add_no_multi_seg_config(self, node):
"""Add No Multi Seg configuration for node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: 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:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'no_multi_seg_config' in self._nodeconfig[hostname]:
+ if 'no_multi_seg_config' not in self._nodeconfig[hostname]:
self._nodeconfig[hostname]['no_multi_seg_config'] = []
- self._nodeconfig[hostname]['no_multi_seg_config'].append(
- "no-multi-seg")
- logger.debug('Setting hostname {} config with {}'.\
- format(hostname, "no-multi-seg"))
+ self._nodeconfig[hostname]['no_multi_seg_config'].append("no-multi-seg")
+ 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
+ :returns: 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:
+ if hostname not in self._nodeconfig:
self._nodeconfig[hostname] = {}
- if not 'enable_vhost_user' in self._nodeconfig[hostname]:
+ if 'enable_vhost_user' not 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"))
+ self._nodeconfig[hostname]['enable_vhost_user'].\
+ append("enable-vhost-user")
+ logger.debug('Setting hostname {} config with {}'.
+ format(hostname, "enable-vhost-user"))
+
+ def add_snat_config(self, node):
+ """Add SNAT configuration for the node.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: nothing
+ """
+ if node['type'] != NodeType.DUT:
+ raise ValueError('Node type is not a DUT')
+ hostname = Topology.get_node_hostname(node)
+ if hostname not in self._nodeconfig:
+ self._nodeconfig[hostname] = {}
+ if 'snat_config' not in self._nodeconfig[hostname]:
+ self._nodeconfig[hostname]['snat_config'] = []
+ self._nodeconfig[hostname]['snat_config'].append("deterministic")
+ logger.debug('Setting hostname {} config with {}'.
+ format(hostname, "SNAT"))
def add_cryptodev_config(self, node, count):
"""Add cryptodev configuration for node.
@@ -276,7 +292,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -291,7 +307,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -306,7 +322,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -337,7 +353,7 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: nothing
"""
if node['type'] != NodeType.DUT:
raise ValueError('Node type is not a DUT')
@@ -352,45 +368,59 @@ class VppConfigGenerator(object):
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: 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]['rxqueues_config'] = []
- logger.debug('Clearing rxqueues config for hostname {}.'.\
- format(hostname))
+ logger.debug('Clearing rxqueues config for hostname {}.'.
+ format(hostname))
def remove_no_multi_seg_config(self, node):
"""Remove No Multi Seg configuration from node.
:param node: DUT node.
:type node: dict
- :return: nothing
+ :returns: 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]['no_multi_seg_config'] = []
- logger.debug('Clearing No Multi Seg config for hostname {}.'.\
- format(hostname))
+ 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
+ :returns: 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))
+ logger.debug('Clearing enable-vhost-user config for hostname {}.'.
+ format(hostname))
+
+ def remove_snat_config(self, node):
+ """Remove SNAT configuration for the node.
+
+ :param node: DUT node.
+ :type node: dict
+ :returns: 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]['snat_config'] = []
+ logger.debug('Clearing SNAT config for hostname {}.'.format(hostname))
def apply_config(self, node, waittime=5, retries=12):
"""Generate and apply VPP configuration for node.
@@ -404,6 +434,8 @@ class VppConfigGenerator(object):
:type node: dict
:type waittime: int
:type retries: int
+ :raises RuntimeError: If writing config file failed, or restarting of
+ VPP failed.
"""
if node['type'] != NodeType.DUT:
@@ -420,6 +452,7 @@ class VppConfigGenerator(object):
enablevhostuser = ""
cryptodevconfig = ""
uiodriverconfig = ""
+ snatconfig = ""
if hostname in self._nodeconfig:
cfg = self._nodeconfig[hostname]
@@ -451,6 +484,11 @@ class VppConfigGenerator(object):
if 'enable_vhost_user' in cfg:
enablevhostuser = " " + "\n ".join(cfg['enable_vhost_user'])
+ if 'snat_config' in cfg:
+ snatconfig = "snat {\n"
+ snatconfig += " " + "\n ".join(cfg['snat_config'])
+ snatconfig += "\n}"
+
vppconfig = VPP_CONFIG_TEMPLATE.format(cpuconfig=cpuconfig,
pciconfig=pciconfig,
cryptodevconfig=cryptodevconfig,
@@ -460,7 +498,8 @@ class VppConfigGenerator(object):
rxqueuesconfig=rxqueuesconfig,
txqueuesconfig=txqueuesconfig,
nomultiseg=nomultiseg,
- enablevhostuser=enablevhostuser)
+ enablevhostuser=enablevhostuser,
+ snatconfig=snatconfig)
logger.debug('Writing VPP config to host {}: "{}"'.format(hostname,
vppconfig))
@@ -517,7 +556,6 @@ class VppConfigGenerator(object):
(ret, stdout, stderr) = \
ssh.exec_command('echo show hardware-interfaces | '
'nc 0 5002')
-
if ret == 0:
vpp_is_running = True
else:
diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py
index 7b15998be0..961f7e2ee8 100644
--- a/resources/libraries/python/ssh.py
+++ b/resources/libraries/python/ssh.py
@@ -285,7 +285,7 @@ class SSH(object):
logger.trace('SCP {0} to {1}:{2}'.format(
local_path, self._ssh.get_transport().getpeername(), remote_path))
# SCPCLient takes a paramiko transport as its only argument
- scp = SCPClient(self._ssh.get_transport())
+ scp = SCPClient(self._ssh.get_transport(), socket_timeout=10)
start = time()
scp.put(local_path, remote_path)
scp.close()