From: wang fei <feix.y.wang@intel.com>
To: dts@dpdk.org
Cc: wang fei <feix.y.wang@intel.com>
Subject: [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
Date: Wed, 20 Sep 2017 20:03:21 +0800 [thread overview]
Message-ID: <1505909001-49728-1-git-send-email-feix.y.wang@intel.com> (raw)
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
reply other threads:[~2017-09-20 9:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505909001-49728-1-git-send-email-feix.y.wang@intel.com \
--to=feix.y.wang@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).