def _watcher_parser_v2(conf, logname, prom_client): logger = config_parser_util.get_logger(logname) result = [] dps = {} for faucet_file in conf['faucet_configs']: _, dp_list = dp_parser(faucet_file, logname) if dp_list: for dp in dp_list: dps[dp.name] = dp dbs = conf.pop('dbs') for name, dictionary in list(conf['watchers'].items()): for dp_name in dictionary['dps']: if dp_name not in dps: logger.error('dp %s metered but not configured', dp_name) continue dp = dps[dp_name] watcher = WatcherConf(name, dictionary, prom_client) watcher.add_db(dbs[watcher.db]) watcher.add_dp(dp) result.append(watcher) return result
def _config_parser_v2(config_file, logname): logger = config_parser_util.get_logger(logname) config_path = config_parser_util.dp_config_path(config_file) config_hashes = {} top_confs = {} for top_conf in V2_TOP_CONFS: top_confs[top_conf] = {} if not config_parser_util.dp_include( config_hashes, config_path, logname, top_confs): logger.critical('error found while loading config file: %s', config_path) return None if not top_confs['dps']: logger.critical('DPs not configured in file: %s', config_path) return None dps = _dp_parser_v2( logger, top_confs['acls'], top_confs['dps'], top_confs['meters'], top_confs['routers'], top_confs['vlans']) return (config_hashes, dps)
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
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