From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id AECD3567E for ; Thu, 6 Aug 2015 14:35:31 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 06 Aug 2015 05:35:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,622,1432623600"; d="scan'208";a="779021258" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 06 Aug 2015 05:35:29 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t76CZSUT010596; Thu, 6 Aug 2015 20:35:28 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t76CZPPw003743; Thu, 6 Aug 2015 20:35:27 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t76CZPQB003739; Thu, 6 Aug 2015 20:35:25 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 6 Aug 2015 20:35:19 +0800 Message-Id: <1438864522-3699-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1438864522-3699-1-git-send-email-yong.liu@intel.com> References: <1438864522-3699-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 1/4] Support load crbs configuration file X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2015 12:35:32 -0000 From: Marvin Liu Move CRBs configruations from internal python file to configuration file. Signed-off-by: Marvin Liu 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