From 4e48e84741d3dd00417c239f6e98f4a0fbfa586a Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Tue, 19 Dec 2017 08:48:11 +0000 Subject: trafficgen: Postponed call of connect() In order to support execution of SW traffic generator inside VM, we have to postpone the call of connect() method from traffic controller. Currently it is called during initialization phase, when VMs are not active and thus connect() would always fail. This patch moves the call of connect() inside configure() method, which is called later when VMs are up and running. This modification allows to configure VM to VM scenario, where 1st VM is running a loopback application and 2nd one executes one of supported SW traffic generators, i.e. T-Rex or MoonGen. Change-Id: Ifeb659aadaa2e1cd5975564965e1719c1e72a12e Signed-off-by: Martin Klozik Reviewed-by: Al Morton Reviewed-by: Christian Trautman Reviewed-by: Sridhar Rao Reviewed-by: Trevor Cooper --- core/traffic_controller.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/traffic_controller.py b/core/traffic_controller.py index d6e7629c..de82dddf 100644 --- a/core/traffic_controller.py +++ b/core/traffic_controller.py @@ -43,6 +43,7 @@ class TrafficController(object): self._duration = None self._lossrate = None self._packet_sizes = None + self._connected = False self._mode = str(settings.getValue('mode')).lower() self._results = [] @@ -51,6 +52,10 @@ class TrafficController(object): """Set configuration values just before test execution so they can be changed during runtime by test steps. """ + if not self._connected: + self._traffic_gen_class.connect() + self._connected = True + self._duration = int(settings.getValue('TRAFFICGEN_DURATION')) self._lossrate = float(settings.getValue('TRAFFICGEN_LOSSRATE')) self._packet_sizes = settings.getValue('TRAFFICGEN_PKT_SIZES') @@ -62,7 +67,7 @@ class TrafficController(object): def __enter__(self): """Call initialisation function. """ - self._traffic_gen_class.connect() + pass def __exit__(self, type_, value, traceback): """Stop traffic, clean up. -- cgit 1.2.3-korg