aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/TrafficGenerator.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2017-11-10 09:06:32 +0100
committerPeter Mikus <pmikus@cisco.com>2018-01-02 07:47:12 +0000
commitab94abd6fea7e4015c3fdc3130beb35b59582d58 (patch)
treea3cd8c99b04826a06061d1ec40c22ea9554f741c /resources/libraries/python/TrafficGenerator.py
parent7cb42e0a9f7785a7ffbc6076a1d5784b203cf9eb (diff)
Upgrade to T-rex v2.34
Change-Id: I7e18ba8beaac507af376a859821ef7d571cbff80 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/TrafficGenerator.py')
-rw-r--r--resources/libraries/python/TrafficGenerator.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 1680438625..88adcc4542 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -184,19 +184,17 @@ class TrafficGenerator(object):
self._node = tg_node
if tg_node['subtype'] == NodeSubTypeTG.TREX:
- trex_path = "/opt/trex-core-2.29"
+ trex_path = "/opt/trex-core-2.34"
ssh = SSH()
ssh.connect(tg_node)
- (ret, stdout, stderr) = ssh.exec_command(
+ (ret, _, _) = ssh.exec_command(
"sudo -E sh -c '{}/resources/tools/trex/"
"trex_installer.sh'".format(Constants.REMOTE_FW_DIR),
timeout=1800)
if int(ret) != 0:
- logger.error('TRex installation failed: {0}'.format(
- stdout + stderr))
- raise RuntimeError('Installation of TG failed')
+ raise RuntimeError('TRex installation failed.')
if1_pci = topo.get_interface_pci_addr(tg_node, tg_if1)
if2_pci = topo.get_interface_pci_addr(tg_node, tg_if2)
@@ -229,7 +227,7 @@ class TrafficGenerator(object):
if1_adj_mac_hex = "0x"+if1_adj_mac.replace(":", ",0x")
if2_adj_mac_hex = "0x"+if2_adj_mac.replace(":", ",0x")
- (ret, stdout, stderr) = ssh.exec_command(
+ (ret, _, _) = ssh.exec_command(
"sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
"- port_limit : 2\n"
" version : 2\n"
@@ -244,8 +242,6 @@ class TrafficGenerator(object):
if1_adj_mac_hex, if1_mac_hex,
if2_adj_mac_hex, if2_mac_hex))
if int(ret) != 0:
- logger.error("failed to create t-rex config: {}"\
- .format(stdout + stderr))
raise RuntimeError('trex config generation error')
max_startup_retries = 3
@@ -255,20 +251,20 @@ class TrafficGenerator(object):
"sh -c 'pgrep t-rex && sudo pkill t-rex && sleep 3'")
# configure T-rex
- (ret, stdout, stderr) = ssh.exec_command(
+ (ret, _, _) = ssh.exec_command(
"sh -c 'cd {0}/scripts/ && sudo ./trex-cfg'"\
.format(trex_path))
if int(ret) != 0:
- logger.error('trex-cfg failed: {0}'.format(stdout + stderr))
raise RuntimeError('trex-cfg failed')
# start T-rex
(ret, _, _) = ssh.exec_command(
"sh -c 'cd {0}/scripts/ && "
- "sudo nohup ./t-rex-64 -i -c 7 --iom 0 > /dev/null 2>&1 &'"
- "> /dev/null"\
+ "sudo nohup ./t-rex-64 -i -c 7 --iom 0 > /tmp/trex.log "
+ "2>&1 &' > /dev/null"\
.format(trex_path))
if int(ret) != 0:
+ ssh.exec_command("sh -c 'cat /tmp/trex.log'")
raise RuntimeError('t-rex-64 startup failed')
# get T-rex server info
@@ -301,10 +297,9 @@ class TrafficGenerator(object):
if node['subtype'] == NodeSubTypeTG.TREX:
ssh = SSH()
ssh.connect(node)
- (ret, stdout, stderr) = ssh.exec_command(
+ (ret, _, _) = ssh.exec_command(
"sh -c 'sudo pkill t-rex && sleep 3'")
if int(ret) != 0:
- logger.error('pkill t-rex failed: {0}'.format(stdout + stderr))
raise RuntimeError('pkill t-rex failed')
@staticmethod