diff options
author | Marvin Liu <yong.liu@intel.com> | 2015-08-07 13:36:08 +0800 |
---|---|---|
committer | Marvin Liu <yong.liu@intel.com> | 2015-08-13 16:13:36 +0800 |
commit | 44b044c3f9a1758ef37826302b2c2bcb4a6d70d0 (patch) | |
tree | ad9a1205fff4519ea9f76eea1951fc22f7906a2f | |
parent | 1851d5c4c6e29a2f1838a1de475f68945df6c1c5 (diff) | |
download | dts-44b044c3f9a1758ef37826302b2c2bcb4a6d70d0.zip dts-44b044c3f9a1758ef37826302b2c2bcb4a6d70d0.tar.gz dts-44b044c3f9a1758ef37826302b2c2bcb4a6d70d0.tar.xz |
Support load crbs configuration file
Move CRBs configruations from internal python file to configuration file.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
-rw-r--r-- | framework/config.py | 60 |
1 files changed, 59 insertions, 1 deletions
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() |