NFVBENCH-144 Trex cannot take account NFVBench config (platform thread id 0) 37/68237/2
authorfmenguy <francoisregis.menguy@orange.com>
Mon, 15 Jul 2019 12:15:53 +0000 (14:15 +0200)
committerfmenguy <francoisregis.menguy@orange.com>
Mon, 15 Jul 2019 15:44:49 +0000 (17:44 +0200)
Change-Id: I9f9891dcc2dd446068ba577322680216f03cac35
Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
nfvbench/traffic_server.py

index 94e5694..4dc7dce 100644 (file)
@@ -97,11 +97,10 @@ class TRexTrafficServer(TrafficServer):
                                          prefix=generator_config.name,
                                          limit_memory=generator_config.limit_memory,
                                          ifs=ifs)
-        if generator_config.platform.master_thread_id and \
-           generator_config.platform.latency_thread_id:
+        if self.__check_platform_config(generator_config):
             try:
                 platform = """
-              platform     :
+          platform     :
             master_thread_id  : {master_thread_id}
             latency_thread_id : {latency_thread_id}
             dual_if:""".format(master_thread_id=generator_config.platform.master_thread_id,
@@ -122,6 +121,13 @@ class TRexTrafficServer(TrafficServer):
                 pass
         return result
 
+    def __check_platform_config(self, generator_config):
+        return hasattr(generator_config, 'platform') \
+            and hasattr(generator_config.platform, "master_thread_id") \
+            and generator_config.platform.master_thread_id is not None \
+            and hasattr(generator_config.platform, "latency_thread_id") \
+            and generator_config.platform.latency_thread_id is not None
+
     def check_config_updated(self, generator_config):
         existing_config = self.__load_config(filename='/etc/trex_cfg.yaml')
         new_config = yaml.safe_load(self.__prepare_config(generator_config))