From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 298005A45 for ; Fri, 7 Aug 2015 07:36:20 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 06 Aug 2015 22:36:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,627,1432623600"; d="scan'208";a="743928686" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 06 Aug 2015 22:36:19 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t775aH0a004635; Fri, 7 Aug 2015 13:36:17 +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 t775aFJR032684; Fri, 7 Aug 2015 13:36:17 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t775aERb032680; Fri, 7 Aug 2015 13:36:14 +0800 From: Yong Liu To: dts@dpdk.org Date: Fri, 7 Aug 2015 13:36:08 +0800 Message-Id: <1438925771-32641-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1438925771-32641-1-git-send-email-yong.liu@intel.com> References: <1438925771-32641-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH V2 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: Fri, 07 Aug 2015 05:36:21 -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..e7e5246 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,60 @@ 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 == 'os': + crb['OS'] = 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 +272,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