test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 0/4] Load Ixia information for configuration file
@ 2015-08-10  8:50 Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 1/4] Support load ixia " Yong Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yong Liu @ 2015-08-10  8:50 UTC (permalink / raw)
  To: dts

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

All configuration for running DTS will be moved to files. This patch set will
move ixia related settings from python module to file.

Marvin Liu (4):
  Support load ixia configuration file
  Add ixia configuration file
  Load configuration file replace of import object
  Remove useless file ixiacfg.py

 conf/ixia.cfg        | 13 +++++++++++
 framework/config.py  | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 framework/etgen.py   | 13 ++++++-----
 framework/ixiacfg.py | 28 -----------------------
 4 files changed, 84 insertions(+), 33 deletions(-)
 create mode 100644 conf/ixia.cfg
 delete mode 100644 framework/ixiacfg.py

-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH 1/4] Support load ixia configuration file
  2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for configuration file Yong Liu
@ 2015-08-10  8:50 ` Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 2/4] Add " Yong Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yong Liu @ 2015-08-10  8:50 UTC (permalink / raw)
  To: dts

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH 2/4] Add ixia configuration file
  2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for configuration file Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 1/4] Support load ixia " Yong Liu
@ 2015-08-10  8:50 ` 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
  3 siblings, 0 replies; 5+ messages in thread
From: Yong Liu @ 2015-08-10  8:50 UTC (permalink / raw)
  To: dts

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

This is sample file for ixia configuration. User need configure three options
"ixia_version", "ixia_ip" and "ixia_ports".

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

diff --git a/conf/ixia.cfg b/conf/ixia.cfg
new file mode 100644
index 0000000..92fd496
--- /dev/null
+++ b/conf/ixia.cfg
@@ -0,0 +1,13 @@
+# IXIA port Configuration
+# IxiaGroup: Group name for IXIA ports
+# Version  : IXIA TCL server version
+# IP       : IXIA server IP address
+# Ports    : [IXIA port list]
+[IXIA Group]
+ixia_version=6.62
+ixia_ip=xxx.xxx.xxx.xxx
+ixia_ports=
+    card=1,port=1;
+    card=1,port=2;
+    card=1,port=3;
+    card=1,port=4;
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH 3/4] Load configuration file replace of import object
  2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for configuration file Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 1/4] Support load ixia " Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 2/4] Add " Yong Liu
@ 2015-08-10  8:50 ` Yong Liu
  2015-08-10  8:50 ` [dts] [PATCH 4/4] Remove useless file ixiacfg.py Yong Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Yong Liu @ 2015-08-10  8:50 UTC (permalink / raw)
  To: dts

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

Support configuration file based ixia options.

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

diff --git a/framework/etgen.py b/framework/etgen.py
index 1803a1f..508439b 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -33,7 +33,7 @@ import re
 import string
 import time
 import dts
-import ixiacfg
+from config import IxiaConf
 from ssh_connection import SSHConnection
 from settings import SCAPY2IXIA
 from logger import getLogger
@@ -147,16 +147,19 @@ class IxiaPacketGenerator(SSHConnection):
         self.conRelation = {}
 
         ixiaRef = self.tester.get_external_traffic_generator()
-        if ixiaRef is None or ixiaRef not in ixiacfg.ixiaPorts:
+
+        ixiacfg = IxiaConf()
+        ixiaPorts = ixiacfg.load_ixia_config()
+        if ixiaRef is None or ixiaRef not in ixiaPorts:
             return
 
-        self.ixiaVersion = ixiacfg.ixiaPorts[ixiaRef]["Version"]
-        self.ports = ixiacfg.ixiaPorts[ixiaRef]["Ports"]
+        self.ixiaVersion = ixiaPorts[ixiaRef]["Version"]
+        self.ports = ixiaPorts[ixiaRef]["Ports"]
 
         self.logger.info(self.ixiaVersion)
         self.logger.info(self.ports)
 
-        self.tclServerIP = ixiacfg.ixiaPorts[ixiaRef]["IP"]
+        self.tclServerIP = ixiaPorts[ixiaRef]["IP"]
 
         # prepare tcl shell and ixia library
         self.send_expect("tclsh", "% ")
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH 4/4] Remove useless file ixiacfg.py
  2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for configuration file Yong Liu
                   ` (2 preceding siblings ...)
  2015-08-10  8:50 ` [dts] [PATCH 3/4] Load configuration file replace of import object Yong Liu
@ 2015-08-10  8:50 ` Yong Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Yong Liu @ 2015-08-10  8:50 UTC (permalink / raw)
  To: dts

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

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

diff --git a/framework/ixiacfg.py b/framework/ixiacfg.py
deleted file mode 100644
index 579cda9..0000000
--- a/framework/ixiacfg.py
+++ /dev/null
@@ -1,28 +0,0 @@
-"""
-ixiaPorts Structure
-
-IxiaGroup: {
-Version : IXIA TCL server version
-IP      : IXIA server IP address
-Ports   : [IXIA port list]
-},
-
-IxiaGroup: {
-Version : IXIA TCL server version
-IP      : IXIA server IP address
-Ports   : [IXIA ports list]
-}
-"""
-# IXIA configure file
-ixiaPorts = {
-    'Group1': {"Version": "6.62",
-               "IP": "10.239.128.121",
-               "Ports": [
-                   {"card": 4, "port": 5},
-                   {"card": 4, "port": 6},
-                   {"card": 4, "port": 7},
-                   {"card": 4, "port": 8}
-               ]
-               }
-
-}
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-10  8:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-10  8:50 [dts] [PATCH 0/4] Load Ixia information for configuration file Yong Liu
2015-08-10  8:50 ` [dts] [PATCH 1/4] Support load ixia " Yong Liu
2015-08-10  8:50 ` [dts] [PATCH 2/4] Add " 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

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).