[dts] [PATCH 1/4] Support load crbs configuration file

Xu, HuilongX huilongx.xu at intel.com
Fri Aug 7 03:58:03 CEST 2015


Hi yong,
In crbs dict could you add key 'os'.
If not os config, maybe  can't support freebsd test.

> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Yong Liu
> Sent: Thursday, August 06, 2015 8:35 PM
> To: dts at dpdk.org
> Subject: [dts] [PATCH 1/4] Support load crbs configuration file
> 
> From: Marvin Liu <yong.liu at intel.com>
> 
> Move CRBs configruations from internal python file to configuration file.
> 
> Signed-off-by: Marvin Liu <yong.liu at intel.com>
> 
> diff --git a/framework/config.py b/framework/config.py
> index 65cecd4..f099a5d 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,58 @@ 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 == '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 +270,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



More information about the dts mailing list