Esempio n. 1
0
def watcher_parser(config_file, logname, prom_client):
    """Return Watcher instances from config."""
    conf, _ = config_parser_util.read_config(config_file, logname)
    conf_hash = config_parser_util.config_file_hash(config_file)
    faucet_config_files, faucet_conf_hashes, result = _watcher_parser_v2(
        conf, logname, prom_client)
    return conf_hash, faucet_config_files, faucet_conf_hashes, result
Esempio n. 2
0
def dp_parser(config_file, logname):
    logger = config_parser_util.get_logger(logname)
    conf = config_parser_util.read_config(config_file, logname)
    config_hashes = None
    dps = None

    if conf is not None:
        version = conf.pop('version', 2)
        if version != 2:
            logger.fatal('Only config version 2 is supported')

        config_hashes, dps = _config_parser_v2(config_file, logname)
    return config_hashes, dps
Esempio n. 3
0
def dp_parser(config_file, logname):
    """Parse a config file into DP configuration objects with hashes of config include/files."""
    conf = config_parser_util.read_config(config_file, logname)
    config_hashes = None
    dps = None

    test_config_condition(conf is None, 'Config file is empty')
    test_config_condition(not isinstance(conf, dict), 'Config file does not have valid syntax')
    version = conf.pop('version', 2)
    test_config_condition(version != 2, 'Only config version 2 is supported')
    config_hashes, dps = _config_parser_v2(config_file, logname)
    test_config_condition(dps is None, 'no DPs are not defined')

    return config_hashes, dps
Esempio n. 4
0
def dp_parser(config_file, logname):
    """Parse a config file into DP configuration objects with hashes of config include/files."""
    conf = config_parser_util.read_config(config_file, logname)
    config_hashes = None
    dps = None

    test_config_condition(conf is None, 'Config file is empty')
    test_config_condition(not isinstance(conf, dict), 'Config file does not have valid syntax')
    version = conf.pop('version', 2)
    test_config_condition(version != 2, 'Only config version 2 is supported')
    config_hashes, dps = _config_parser_v2(config_file, logname)
    test_config_condition(dps is None, 'no DPs are not defined')

    return config_hashes, dps
Esempio n. 5
0
def dp_parser(config_file, logname):
    conf = config_parser_util.read_config(config_file, logname)
    config_hashes = None
    dps = None

    try:
        assert conf is not None, 'Config file is empty'
        assert isinstance(conf, dict), 'Config file does not have valid syntax'
        version = conf.pop('version', 2)
        assert version == 2, 'Only config version 2 is supported'
        config_hashes, dps = _config_parser_v2(config_file, logname)
        assert dps is not None, 'no DPs are not defined'

    except AssertionError as err:
        raise InvalidConfigError(err)

    return config_hashes, dps
Esempio n. 6
0
def dp_parser(config_file, logname):
    logger = config_parser_util.get_logger(logname)
    conf = config_parser_util.read_config(config_file, logname)
    if conf is None:
        return None
    version = conf.pop('version', 2)
    if version != 2:
        logger.fatal('Only config version 2 is supported')

    config_hashes, dps = _config_parser_v2(config_file, logname)
    if dps is not None:
        for dp in dps:
            try:
                dp.finalize_config(dps)
            except AssertionError as err:
                logger.exception('Error finalizing datapath configs: %s', err)
        for dp in dps:
            dp.resolve_stack_topology(dps)
    return config_hashes, dps
Esempio n. 7
0
def watcher_parser(config_file, logname, prom_client):
    """Return Watcher instances from config."""
    conf = config_parser_util.read_config(config_file, logname)
    return _watcher_parser_v2(conf, logname, prom_client)
Esempio n. 8
0
def watcher_parser(config_file, logname, prom_client):
    conf = config_parser_util.read_config(config_file, logname)
    return _watcher_parser_v2(conf, logname, prom_client)
Esempio n. 9
0
def watcher_parser(config_file, logname, prom_client):
    """Return Watcher instances from config."""
    conf = config_parser_util.read_config(config_file, logname)
    return _watcher_parser_v2(conf, logname, prom_client)