test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH 1/4] Support load ixia configuration file
Date: Mon, 10 Aug 2015 16:50:21 +0800	[thread overview]
Message-ID: <1439196624-10377-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1439196624-10377-1-git-send-email-yong.liu@intel.com>

From: Marvin Liu <yong.liu@intel.com>

Move ixia configurations from internal python file to configuration file.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/config.py b/framework/config.py
index e7e5246..10624f0 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -42,6 +42,7 @@ from exception import ConfigParseException, VirtConfigParseException
 PORTCONF = "conf/ports.cfg"
 CRBCONF = "conf/crbs.cfg"
 VIRTCONF = "conf/virt_global.cfg"
+IXIACONF = "conf/ixia.cfg"
 
 
 class UserConf():
@@ -239,12 +240,70 @@ class CrbsConf(UserConf):
             self.crbs_cfg.append(crb)
         return self.crbs_cfg
 
+
+class IxiaConf(UserConf):
+
+    def __init__(self, ixia_conf=IXIACONF):
+        self.config_file = ixia_conf
+        self.ixia_cfg = {}
+        try:
+            self.ixia_conf = UserConf(self.config_file)
+        except ConfigParseException:
+            self.ixia_conf = None
+            raise ConfigParseException
+
+    def load_ixia_config(self):
+        port_reg = r'card=(\d+),port=(\d+)'
+        groups = self.ixia_conf.get_sections()
+        if not groups:
+            return self.ixia_cfg
+
+        for group in groups:
+            ixia_group = {}
+            ixia_confs = self.ixia_conf.load_section(group)
+            if not ixia_confs:
+                continue
+
+            # convert file configuration to dts ixiacfg
+            for conf in ixia_confs:
+                key, value = conf
+                if key == 'ixia_version':
+                    ixia_group['Version'] = value
+                elif key == 'ixia_ip':
+                    ixia_group['IP'] = value
+                elif key == 'ixia_ports':
+                    ports = self.ixia_conf.load_config(value)
+                    ixia_ports = []
+                    for port in ports:
+                        m = re.match(port_reg, port)
+                        if m:
+                            ixia_port = {}
+                            ixia_port["card"] = int(m.group(1))
+                            ixia_port["port"] = int(m.group(2))
+                            ixia_ports.append(ixia_port)
+                    ixia_group['Ports'] = ixia_ports
+
+            if 'Version' not in ixia_group:
+                print 'ixia configuration file request ixia_version option!!!'
+                continue
+            if 'IP' not in ixia_group:
+                print 'ixia configuration file request ixia_ip option!!!'
+                continue
+            if 'Ports' not in ixia_group:
+                print 'ixia configuration file request ixia_ports option!!!'
+                continue
+
+            self.ixia_cfg[group] = ixia_group
+
+        return self.ixia_cfg
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(
         description="Load DTS configuration files")
     parser.add_argument("-p", "--portconf", default=PORTCONF)
     parser.add_argument("-c", "--crbconf", default=CRBCONF)
     parser.add_argument("-v", "--virtconf", default=VIRTCONF)
+    parser.add_argument("-i", "--ixiaconf", default=IXIACONF)
     args = parser.parse_args()
 
     # not existed configuration file
@@ -276,3 +335,7 @@ if __name__ == '__main__':
     # example for crbs configuration file
     crbsconf = CrbsConf(CRBCONF)
     print crbsconf.load_crbs_config()
+
+    # example for ixia configuration file
+    ixiaconf = IxiaConf(IXIACONF)
+    print ixiaconf.load_ixia_config()
-- 
1.9.3

  reply	other threads:[~2015-08-10  8:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for " Yong Liu
2015-08-10  8:50 ` Yong Liu [this message]
2015-08-10  8:50 ` [dts] [PATCH 2/4] Add ixia " Yong Liu
2015-08-10  8:50 ` [dts] [PATCH 3/4] Load configuration file replace of import object Yong Liu
2015-08-10  8:50 ` [dts] [PATCH 4/4] Remove useless file ixiacfg.py Yong Liu

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=1439196624-10377-2-git-send-email-yong.liu@intel.com \
    --to=yong.liu@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).