test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [Patch V1] framework/config.py: Add the class of parsing the configuration file of packet generator sent this patch on behalf of chen hongli
@ 2017-09-20 12:03 wang fei
  0 siblings, 0 replies; only message in thread
From: wang fei @ 2017-09-20 12:03 UTC (permalink / raw)
  To: dts; +Cc: wang fei

Signed-off-by: wang fei <feix.y.wang@intel.com>
---
 framework/config.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/framework/config.py b/framework/config.py
index 9e514a7..b3106ce 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -45,7 +45,7 @@ CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH
 VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH
 IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH
 SUITECONF_SAMPLE = "%s/suite_sample.cfg" % CONFIG_ROOT_PATH
-
+PKTGENCONF = "%s/pktgen.cfg" % CONFIG_ROOT_PATH
 
 class UserConf():
 
@@ -352,6 +352,57 @@ class IxiaConf(UserConf):
 
         return self.ixia_cfg
 
+class PktgenConf(UserConf):
+
+    def __init__(self, pktgen_type='dpdk', pktgen_conf=PKTGENCONF):
+        self.config_file = pktgen_conf
+        self.pktgen_type = pktgen_type
+        self.pktgen_cfg = {}
+        try:
+            self.pktgen_conf = UserConf(self.config_file)
+        except ConfigParseException:
+            self.pktgen_conf = None
+            raise ConfigParseException
+
+    def load_pktgen_config(self):
+        sections = self.pktgen_conf.get_sections()
+        if not sections:
+            return self.pktgen_cfg
+
+        for section in sections:
+            if self.pktgen_type=='dpdk':
+                if section == 'PKTGEN DPDK':
+                    pktgen_confs = self.pktgen_conf.load_section(section)
+                    if not pktgen_confs:
+                        continue
+
+                    # covert file configuration to dts pktgen cfg
+                    for conf in pktgen_confs:
+                        key, value = conf
+                        self.pktgen_cfg[key] = value
+            elif self.pktgen_type=='trex':
+                if section == 'TREX':
+                    pktgen_confs = self.pktgen_conf.load_section(section)
+                    if not pktgen_confs:
+                        continue
+
+                    # covert file configuration to dts pktgen cfg
+                    for conf in pktgen_confs:
+                        key, value = conf
+                        self.pktgen_cfg[key] = value
+            elif self.pktgen_type=='ixia':
+                if section == 'IXIA':
+                    pktgen_confs = self.pktgen_conf.load_section(section)
+                    if not pktgen_confs:
+                        continue
+
+                    # covert file configuration to dts pktgen cfg
+                    for conf in pktgen_confs:
+                        key, value = conf
+                        self.pktgen_cfg[key] = value
+
+        return self.pktgen_cfg
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(
         description="Load DTS configuration files")
-- 
2.7.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-20  9:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20 12:03 [dts] [Patch V1] framework/config.py: Add the class of parsing the configuration file of packet generator sent this patch on behalf of chen hongli wang fei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).