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 8B69E5A5D for ; Mon, 10 Aug 2015 10:50:33 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 10 Aug 2015 01:50:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,644,1432623600"; d="scan'208";a="765493071" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 10 Aug 2015 01:50:32 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t7A8oV7j002150; Mon, 10 Aug 2015 16:50:31 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t7A8oSgh010420; Mon, 10 Aug 2015 16:50:30 +0800 Received: (from yliu84x@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t7A8oSBC010416; Mon, 10 Aug 2015 16:50:28 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 10 Aug 2015 16:50:21 +0800 Message-Id: <1439196624-10377-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1439196624-10377-1-git-send-email-yong.liu@intel.com> References: <1439196624-10377-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 1/4] Support load ixia 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: Mon, 10 Aug 2015 08:50:34 -0000 From: Marvin Liu Move ixia configurations from internal python file to configuration file. Signed-off-by: Marvin Liu 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