X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=nfvbench%2Ftraffic_server.py;h=c87f8c32f0c69530d4029e8d76a7b54bbe78aa57;hb=713ee57033bde0ca01fa34c78add5a709c2cdd54;hp=ac232655dd2c0970cf6bca2c2dd883c3384b3ccc;hpb=547b10033d41b2b9f8445816fceab87ebc4a03cb;p=nfvbench.git diff --git a/nfvbench/traffic_server.py b/nfvbench/traffic_server.py index ac23265..c87f8c3 100644 --- a/nfvbench/traffic_server.py +++ b/nfvbench/traffic_server.py @@ -16,7 +16,7 @@ import os import subprocess import yaml -from log import LOG +from .log import LOG class TrafficServerException(Exception): @@ -49,14 +49,16 @@ class TRexTrafficServer(TrafficServer): mbuf_opt = "--mbuf-factor " + str(generator_config.mbuf_factor) else: mbuf_opt = "" + hdrh_opt = "--hdrh" if generator_config.hdrh else "" # --unbind-unused-ports: for NIC that have more than 2 ports such as Intel X710 # this will instruct trex to unbind all ports that are unused instead of # erroring out with an exception (i40e only) cmd = ['nohup', '/bin/bash', '-c', './t-rex-64 -i -c {} --iom 0 --no-scapy-server ' - '--unbind-unused-ports --close-at-end {} ' + '--unbind-unused-ports --close-at-end {} {} ' '{} {} --cfg {} &> /tmp/trex.log & disown'.format(cores, sw_mode, vlan_opt, + hdrh_opt, mbuf_opt, cfg)] LOG.info(' '.join(cmd)) subprocess.Popen(cmd, cwd=self.trex_dir) @@ -69,7 +71,7 @@ class TRexTrafficServer(TrafficServer): try: result = yaml.safe_load(stream) except yaml.YAMLError as exc: - print exc + print(exc) return result def __save_config(self, generator_config, filename): @@ -95,23 +97,29 @@ 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 hasattr(generator_config, 'mbuf_64') and generator_config.mbuf_64: + result += """ + memory : + mbuf_64 : {mbuf_64}""".format(mbuf_64=generator_config.mbuf_64) + + 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, - latency_thread_id=generator_config.platform.latency_thread_id) + dual_if:""".format(master_thread_id=generator_config.gen_config.platform. + master_thread_id, + latency_thread_id=generator_config.gen_config.platform. + latency_thread_id) result += platform - for core in generator_config.platform.dual_if: + for core in generator_config.gen_config.platform.dual_if: threads = "" try: threads = ",".join([repr(thread) for thread in core.threads]) except TypeError: - LOG.warn("No threads defined for socket %s", core.socket) + LOG.warning("No threads defined for socket %s", core.socket) core_result = """ - socket : {socket} threads : [{threads}]""".format(socket=core.socket, threads=threads) @@ -120,6 +128,13 @@ class TRexTrafficServer(TrafficServer): pass return result + def __check_platform_config(self, generator_config): + return hasattr(generator_config.gen_config, 'platform') \ + and hasattr(generator_config.gen_config.platform, "master_thread_id") \ + and generator_config.gen_config.platform.master_thread_id is not None \ + and hasattr(generator_config.gen_config.platform, "latency_thread_id") \ + and generator_config.gen_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))