def write_emane_configs(self) -> None: emane_configurations = etree.Element("emane_configurations") for node_id, model_configs in self.session.emane.node_configs.items(): node_id, iface_id = utils.parse_iface_config_id(node_id) for model_name, config in model_configs.items(): logger.debug("writing emane config node(%s) model(%s)", node_id, model_name) model_class = self.session.emane.get_model(model_name) emane_configuration = create_emane_model_config( node_id, model_class, config, iface_id) emane_configurations.append(emane_configuration) if emane_configurations.getchildren(): self.scenario.append(emane_configurations)
def get_emane_model_configs_dict( session: Session) -> Dict[int, List[NodeEmaneConfig]]: configs = {} for _id, model_configs in session.emane.node_configs.items(): for model_name in model_configs: model_class = session.emane.get_model(model_name) current_config = session.emane.get_config(_id, model_name) config = get_config_options(current_config, model_class) node_id, iface_id = utils.parse_iface_config_id(_id) iface_id = iface_id if iface_id is not None else -1 node_config = NodeEmaneConfig(model=model_name, iface_id=iface_id, config=config) node_configs = configs.setdefault(node_id, []) node_configs.append(node_config) return configs
def get_emane_model_configs(session: Session) -> List[GetEmaneModelConfig]: configs = [] for _id in session.emane.node_configurations: if _id == -1: continue model_configs = session.emane.node_configurations[_id] for model_name in model_configs: model = session.emane.models[model_name] current_config = session.emane.get_model_config(_id, model_name) config = get_config_options(current_config, model) node_id, iface_id = utils.parse_iface_config_id(_id) iface_id = iface_id if iface_id is not None else -1 model_config = GetEmaneModelConfig(node_id=node_id, model=model_name, iface_id=iface_id, config=config) configs.append(model_config) return configs
def write_emane_configs(self) -> None: emane_global_configuration = create_emane_config(self.session) self.scenario.append(emane_global_configuration) emane_configurations = etree.Element("emane_configurations") for node_id in self.session.emane.nodes(): all_configs = self.session.emane.get_all_configs(node_id) if not all_configs: continue node_id, iface_id = utils.parse_iface_config_id(node_id) for model_name in all_configs: config = all_configs[model_name] logging.debug("writing emane config node(%s) model(%s)", node_id, model_name) model = self.session.emane.models[model_name] emane_configuration = create_emane_model_config( node_id, model, config, iface_id) emane_configurations.append(emane_configuration) if emane_configurations.getchildren(): self.scenario.append(emane_configurations)