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 crbs configuration file
Date: Thu,  6 Aug 2015 20:35:19 +0800	[thread overview]
Message-ID: <1438864522-3699-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1438864522-3699-1-git-send-email-yong.liu@intel.com>

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

Move CRBs configruations 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 65cecd4..f099a5d 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -36,7 +36,7 @@ Generic port and crbs configuration file load function
 import re
 import ConfigParser  # config parse module
 import argparse      # prase arguments module
-
+from settings import IXIA
 from exception import ConfigParseException, VirtConfigParseException
 
 PORTCONF = "conf/ports.cfg"
@@ -185,6 +185,58 @@ class PortConf(UserConf):
             return False
 
 
+class CrbsConf(UserConf):
+    DEF_CRB = {'IP': '', 'name': 'CrownPassCRB1', 'user': '',
+               'pass': '', 'tester IP': '', 'tester pass': '',
+               IXIA: None, 'memory channels': 4,
+               'bypass core0': True}
+
+    def __init__(self, crbs_conf=CRBCONF):
+        self.config_file = crbs_conf
+        self.crbs_cfg = []
+        try:
+            self.crbs_conf = UserConf(self.config_file)
+        except ConfigParseException:
+            self.crbs_conf = None
+            raise ConfigParseException
+
+    def load_crbs_config(self):
+        sections = self.crbs_conf.get_sections()
+        if not sections:
+            return self.crbs_cfg
+
+        for name in sections:
+            crb = self.DEF_CRB.copy()
+            crb_confs = self.crbs_conf.load_section(name)
+            if not crb_confs:
+                continue
+
+            # covert file configuration to dts crbs
+            for conf in crb_confs:
+                key, value = conf
+                if key == 'dut_ip':
+                    crb['IP'] = value
+                elif key == 'dut_user':
+                    crb['user'] = value
+                elif key == 'dut_passwd':
+                    crb['pass'] = value
+                elif key == 'tester_ip':
+                    crb['tester IP'] = value
+                elif key == 'tester_passwd':
+                    crb['tester pass'] = value
+                elif key == 'ixia_group':
+                    crb[IXIA] = value
+                elif key == 'channels':
+                    crb['memory channels'] = int(value)
+                elif key == 'bypass_core0':
+                    if value == 'True':
+                        crb['bypass core0'] = True
+                    else:
+                        crb['bypass core0'] = False
+
+            self.crbs_cfg.append(crb)
+        return self.crbs_cfg
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(
         description="Load DTS configuration files")
@@ -218,3 +270,7 @@ if __name__ == '__main__':
     virtconf = VirtConf(VIRTCONF)
     virtconf.load_virt_config('LIBVIRT')
     print virtconf.get_virt_config()
+
+    # example for crbs configuration file
+    crbsconf = CrbsConf(CRBCONF)
+    print crbsconf.load_crbs_config()
-- 
1.9.3

  reply	other threads:[~2015-08-06 12:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 12:35 [dts] [PATCH 0/4] Load CRBs information from " Yong Liu
2015-08-06 12:35 ` Yong Liu [this message]
2015-08-07  1:58   ` [dts] [PATCH 1/4] Support load crbs " Xu, HuilongX
2015-08-07  4:54     ` Liu, Yong
2015-08-06 12:35 ` [dts] [PATCH 2/4] Add sample " Yong Liu
2015-08-07  2:02   ` Xu, HuilongX
2015-08-07  4:55     ` Liu, Yong
2015-08-06 12:35 ` [dts] [PATCH 3/4] Move function accepted_nic to dts module Yong Liu
2015-08-06 12:35 ` [dts] [PATCH 4/4] Load CRBs information from configuration file 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=1438864522-3699-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).