diff options
-rw-r--r-- | conf/crbs.cfg | 31 | ||||
-rw-r--r-- | conf/ixia.cfg | 13 | ||||
-rw-r--r-- | framework/config.py | 123 | ||||
-rw-r--r-- | framework/crbs.py | 14 | ||||
-rw-r--r-- | framework/dts.py | 25 | ||||
-rw-r--r-- | framework/dut.py | 6 | ||||
-rw-r--r-- | framework/etgen.py | 13 | ||||
-rw-r--r-- | framework/ixiacfg.py | 28 | ||||
-rw-r--r-- | framework/project_dpdk.py | 4 | ||||
-rw-r--r-- | framework/settings.py | 18 |
10 files changed, 202 insertions, 73 deletions
diff --git a/conf/crbs.cfg b/conf/crbs.cfg new file mode 100644 index 0000000..81c5c29 --- /dev/null +++ b/conf/crbs.cfg @@ -0,0 +1,31 @@ +#DUT crbs Configuration +#[DUT IP] +# dut_ip: DUT ip address +# dut_user: Login DUT username +# dut_passwd: Login DUT password +# os: operation system type linux or freebsd +# tester_ip: Tester ip address +# tester_passwd: Tester password +# ixia_group: IXIA group nmae +# channels: Board channel number +# bypass_core0: Whether by pass core0 +[DUT IP1] +dut_ip=xxx.xxx.xxx.xxx +dut_user=root +dut_passwd= +os=linux +tester_ip=xxx.xxx.xxx.xxx +tester_passwd= +ixia_group= +channels=4 +bypass_core0=True +[DUT IP2] +dut_ip=yyy.yyy.yyy.yyy +dut_user=root +dut_passwd= +os=linux +tester_ip=yyy.yyy.yyy.yyy +tester_passwd= +ixia_group= +channels=4 +bypass_core0=True diff --git a/conf/ixia.cfg b/conf/ixia.cfg new file mode 100644 index 0000000..92fd496 --- /dev/null +++ b/conf/ixia.cfg @@ -0,0 +1,13 @@ +# IXIA port Configuration +# IxiaGroup: Group name for IXIA ports +# Version : IXIA TCL server version +# IP : IXIA server IP address +# Ports : [IXIA port list] +[IXIA Group] +ixia_version=6.62 +ixia_ip=xxx.xxx.xxx.xxx +ixia_ports= + card=1,port=1; + card=1,port=2; + card=1,port=3; + card=1,port=4; diff --git a/framework/config.py b/framework/config.py index 65cecd4..10624f0 100644 --- a/framework/config.py +++ b/framework/config.py @@ -36,12 +36,13 @@ 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" CRBCONF = "conf/crbs.cfg" VIRTCONF = "conf/virt_global.cfg" +IXIACONF = "conf/ixia.cfg" class UserConf(): @@ -185,12 +186,124 @@ 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 + + +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 @@ -218,3 +331,11 @@ 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() + + # example for ixia configuration file + ixiaconf = IxiaConf(IXIACONF) + print ixiaconf.load_ixia_config() diff --git a/framework/crbs.py b/framework/crbs.py index 6aa5435..2ff937a 100644 --- a/framework/crbs.py +++ b/framework/crbs.py @@ -3,20 +3,6 @@ Static configuration data for any CRBs that can be used. """ from settings import IXIA -# Todo: modify this script to a config file, like crbs.cfg -crbs = [ - {'IP': '', - 'name': 'CrownPassCRB1', - 'user': '', - 'pass': '', - 'tester IP': '', - 'tester pass': '', - IXIA: None, - 'memory channels': 4, - 'bypass core0': True}, -] - - crbs_desc = { 'CrownPassCRB1': diff --git a/framework/dts.py b/framework/dts.py index 613926c..33ac542 100644 --- a/framework/dts.py +++ b/framework/dts.py @@ -41,7 +41,6 @@ import signal # signal module for debug mode import time # time module for unique output folder import rst # rst file support -from crbs import crbs from tester import Tester from dut import Dut from settings import FOLDERS, NICS, DRIVERS @@ -57,6 +56,7 @@ from logger import getLogger import logger import debugger from virt_scene import VirtScene +from config import CrbsConf from checkCase import * import sys reload(sys) @@ -456,6 +456,10 @@ def run_all(config_file, pkgName, git, patch, skip_setup, excel_report = ExcelReporter(output_dir + '/test_results.xls') stats = StatsReporter(output_dir + '/statistics.txt') + crbInst = None + crbs_conf = CrbsConf() + crbs = crbs_conf.load_crbs_config() + # for all Exectuion sections for section in config.sections(): dts_parse_param(section) @@ -465,7 +469,6 @@ def run_all(config_file, pkgName, git, patch, skip_setup, log_handler.info("\nDUT " + dutIP) # look up in crbs - to find the matching IP - crbInst = None for crb in crbs: if crb['IP'] == dutIP: crbInst = crb @@ -744,3 +747,21 @@ def save_all_results(): """ excel_report.save(result) stats.save(result) + +def accepted_nic(pci_id): + """ + Return True if the pci_id is a known NIC card in the settings file and if + it is selected in the execution file, otherwise it returns False. + """ + global nic + if pci_id not in NICS.values(): + return False + + if nic is 'any': + return True + + else: + if pci_id == NICS[nic]: + return True + + return False diff --git a/framework/dut.py b/framework/dut.py index a5c9db3..1199fc6 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -322,7 +322,7 @@ class Dut(Crb): current_nic = 0 for (pci_bus, pci_id) in self.pci_devices_info: - if settings.accepted_nic(pci_id): + if dts.accepted_nic(pci_id): if self.is_ssh_session_port(pci_bus): continue @@ -345,7 +345,7 @@ class Dut(Crb): current_nic = 0 for (pci_bus, pci_id) in self.pci_devices_info: - if settings.accepted_nic(pci_id): + if dts.accepted_nic(pci_id): if self.is_ssh_session_port(pci_bus): continue @@ -671,7 +671,7 @@ class Dut(Crb): for (pci_bus, pci_id) in self.pci_devices_info: - if not settings.accepted_nic(pci_id): + if not dts.accepted_nic(pci_id): self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id, skipped)) continue diff --git a/framework/etgen.py b/framework/etgen.py index 1803a1f..508439b 100644 --- a/framework/etgen.py +++ b/framework/etgen.py @@ -33,7 +33,7 @@ import re import string import time import dts -import ixiacfg +from config import IxiaConf from ssh_connection import SSHConnection from settings import SCAPY2IXIA from logger import getLogger @@ -147,16 +147,19 @@ class IxiaPacketGenerator(SSHConnection): self.conRelation = {} ixiaRef = self.tester.get_external_traffic_generator() - if ixiaRef is None or ixiaRef not in ixiacfg.ixiaPorts: + + ixiacfg = IxiaConf() + ixiaPorts = ixiacfg.load_ixia_config() + if ixiaRef is None or ixiaRef not in ixiaPorts: return - self.ixiaVersion = ixiacfg.ixiaPorts[ixiaRef]["Version"] - self.ports = ixiacfg.ixiaPorts[ixiaRef]["Ports"] + self.ixiaVersion = ixiaPorts[ixiaRef]["Version"] + self.ports = ixiaPorts[ixiaRef]["Ports"] self.logger.info(self.ixiaVersion) self.logger.info(self.ports) - self.tclServerIP = ixiacfg.ixiaPorts[ixiaRef]["IP"] + self.tclServerIP = ixiaPorts[ixiaRef]["IP"] # prepare tcl shell and ixia library self.send_expect("tclsh", "% ") diff --git a/framework/ixiacfg.py b/framework/ixiacfg.py deleted file mode 100644 index 579cda9..0000000 --- a/framework/ixiacfg.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -ixiaPorts Structure - -IxiaGroup: { -Version : IXIA TCL server version -IP : IXIA server IP address -Ports : [IXIA port list] -}, - -IxiaGroup: { -Version : IXIA TCL server version -IP : IXIA server IP address -Ports : [IXIA ports list] -} -""" -# IXIA configure file -ixiaPorts = { - 'Group1': {"Version": "6.62", - "IP": "10.239.128.121", - "Ports": [ - {"card": 4, "port": 5}, - {"card": 4, "port": 6}, - {"card": 4, "port": 7}, - {"card": 4, "port": 8} - ] - } - -} diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py index 7b6e1ae..e0009d3 100644 --- a/framework/project_dpdk.py +++ b/framework/project_dpdk.py @@ -39,7 +39,7 @@ from crb import Crb from dut import Dut from tester import Tester from logger import getLogger -from settings import IXIA, accepted_nic +from settings import IXIA class DPDKdut(Dut): @@ -112,7 +112,7 @@ class DPDKdut(Dut): binding_list = '' for (pci_bus, pci_id) in self.pci_devices_info: - if accepted_nic(pci_id): + if dts.accepted_nic(pci_id): binding_list += '%s,' % (pci_bus) self.send_expect("kldunload if_ixgbe.ko", "#") diff --git a/framework/settings.py b/framework/settings.py index 631bd32..6b02e4d 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -33,7 +33,6 @@ Folders for framework running enviornment. """ import re import socket -import dts FOLDERS = { 'Framework': 'framework', @@ -179,23 +178,6 @@ def get_nic_driver(pci_id): return driver -def accepted_nic(pci_id): - """ - Return True if the pci_id is a known NIC card in the settings file and if - it is selected in the execution file, otherwise it returns False. - """ - if pci_id not in NICS.values(): - return False - - if dts.nic is 'any': - return True - - else: - if pci_id == NICS[dts.nic]: - return True - - return False - def get_netdev(crb, pci): for port in crb.ports_info: if pci == port['pci']: |