daemon: adjustments to emane model post startup to accept an interface, since settings may be unique per interface, updated tdma to use this information for trying to initialize its tdma schedule properly

This commit is contained in:
Blake Harnden 2021-05-25 12:14:28 -07:00
parent 8d5c3bd212
commit 820539191d
3 changed files with 18 additions and 16 deletions

View file

@ -446,17 +446,17 @@ class EmaneManager:
"""
Retransmit location events now that all NEMs are active.
"""
if not self.genlocationevents():
return
events_enabled = self.genlocationevents()
with self._emane_node_lock:
for node_id in sorted(self._emane_nets):
emane_net = self._emane_nets[node_id]
logger.debug(
"post startup for emane node: %s - %s", emane_net.id, emane_net.name
)
emane_net.model.post_startup()
for iface in emane_net.get_ifaces():
iface.setposition()
emane_net.model.post_startup(iface)
if events_enabled:
iface.setposition()
def reset(self) -> None:
"""

View file

@ -134,10 +134,11 @@ class EmaneModel(WirelessModel):
emanexml.create_phy_xml(self, iface, config)
emanexml.create_transport_xml(iface, config)
def post_startup(self) -> None:
def post_startup(self, iface: CoreInterface) -> None:
"""
Logic to execute after the emane manager is finished with startup.
:param iface: interface for post startup
:return: nothing
"""
logger.debug("emane model(%s) has no post setup tasks", self.name)

View file

@ -9,7 +9,9 @@ from typing import Set
from core import constants, utils
from core.config import Configuration
from core.emane import emanemodel
from core.emane.nodes import EmaneNet
from core.emulator.enumerations import ConfigDataTypes
from core.nodes.interface import CoreInterface
logger = logging.getLogger(__name__)
@ -44,22 +46,21 @@ class EmaneTdmaModel(emanemodel.EmaneModel):
)
cls.mac_config.insert(0, config_item)
def post_startup(self) -> None:
"""
Logic to execute after the emane manager is finished with startup.
:return: nothing
"""
def post_startup(self, iface: CoreInterface) -> None:
# get configured schedule
config = self.session.emane.get_config(self.id, self.name)
if not config:
return
emane_net = self.session.get_node(self.id, EmaneNet)
config = self.session.emane.get_iface_config(emane_net, iface)
schedule = Path(config[self.schedule_name])
if not schedule.is_file():
logger.warning("ignoring invalid tdma schedule: %s", schedule)
logger.error("ignoring invalid tdma schedule: %s", schedule)
return
# initiate tdma schedule
for service in self.session.emane.services.values():
nem_id = self.session.emane.get_nem_id(iface)
if not nem_id:
logger.error("could not find nem for interface")
return
service = self.session.emane.nem_service.get(nem_id)
if service:
device = service.device
logger.info(
"setting up tdma schedule: schedule(%s) device(%s)", schedule, device