From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 2AE3E1F5 for ; Wed, 20 Sep 2017 11:30:57 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 02:30:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,420,1500966000"; d="scan'208";a="902152161" Received: from dpdk-test47.sh.intel.com ([10.67.118.152]) by FMSMGA003.fm.intel.com with ESMTP; 20 Sep 2017 02:30:55 -0700 From: wang fei To: dts@dpdk.org Cc: wang fei Date: Wed, 20 Sep 2017 20:03:21 +0800 Message-Id: <1505909001-49728-1-git-send-email-feix.y.wang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [Patch V1] framework/config.py: Add the class of parsing the configuration file of packet generator sent this patch on behalf of chen hongli 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: Wed, 20 Sep 2017 09:30:57 -0000 Signed-off-by: wang fei --- framework/config.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/framework/config.py b/framework/config.py index 9e514a7..b3106ce 100644 --- a/framework/config.py +++ b/framework/config.py @@ -45,7 +45,7 @@ CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH SUITECONF_SAMPLE = "%s/suite_sample.cfg" % CONFIG_ROOT_PATH - +PKTGENCONF = "%s/pktgen.cfg" % CONFIG_ROOT_PATH class UserConf(): @@ -352,6 +352,57 @@ class IxiaConf(UserConf): return self.ixia_cfg +class PktgenConf(UserConf): + + def __init__(self, pktgen_type='dpdk', pktgen_conf=PKTGENCONF): + self.config_file = pktgen_conf + self.pktgen_type = pktgen_type + self.pktgen_cfg = {} + try: + self.pktgen_conf = UserConf(self.config_file) + except ConfigParseException: + self.pktgen_conf = None + raise ConfigParseException + + def load_pktgen_config(self): + sections = self.pktgen_conf.get_sections() + if not sections: + return self.pktgen_cfg + + for section in sections: + if self.pktgen_type=='dpdk': + if section == 'PKTGEN DPDK': + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + continue + + # covert file configuration to dts pktgen cfg + for conf in pktgen_confs: + key, value = conf + self.pktgen_cfg[key] = value + elif self.pktgen_type=='trex': + if section == 'TREX': + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + continue + + # covert file configuration to dts pktgen cfg + for conf in pktgen_confs: + key, value = conf + self.pktgen_cfg[key] = value + elif self.pktgen_type=='ixia': + if section == 'IXIA': + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + continue + + # covert file configuration to dts pktgen cfg + for conf in pktgen_confs: + key, value = conf + self.pktgen_cfg[key] = value + + return self.pktgen_cfg + if __name__ == '__main__': parser = argparse.ArgumentParser( description="Load DTS configuration files") -- 2.7.4