daemon: cleanup emane transport service in relation to refactoring, silenced stopdaemons for rj45 nodes

This commit is contained in:
Blake Harnden 2020-07-02 23:19:40 -07:00
parent 5f676b27ba
commit 2b3e26b7c2
2 changed files with 37 additions and 65 deletions

View file

@ -134,10 +134,6 @@ class EmaneManager(ModelManager):
:return: net, node, or interface model configuration
"""
model_name = emane_net.model.name
# use the network-wide config values or interface(NEM)-specific values?
if iface is None:
return self.get_configs(node_id=emane_net.id, config_type=model_name)
else:
# don"t use default values when interface config is the same as net
# note here that using iface.node.id as key allows for only one type
# of each model per node;
@ -587,26 +583,18 @@ class EmaneManager(ModelManager):
"""
Kill the appropriate EMANE daemons.
"""
# TODO: we may want to improve this if we had the PIDs from the specific EMANE
# daemons that we"ve started
kill_emaned = "killall -q emane"
kill_transortd = "killall -q emanetransportd"
stop_emane_on_host = False
for node in self.getnodes():
if isinstance(node, Rj45Node):
stop_emane_on_host = True
continue
if node.up:
node.cmd(kill_emaned, wait=False)
# TODO: RJ45 node
if stop_emane_on_host:
try:
utils.cmd(kill_emaned)
utils.cmd(kill_transortd)
utils.cmd(kill_emaned, wait=False)
self.session.distributed.execute(lambda x: x.remote_cmd(kill_emaned))
self.session.distributed.execute(lambda x: x.remote_cmd(kill_transortd))
except CoreCommandError:
logging.exception("error shutting down emane daemons")

View file

@ -1,7 +1,6 @@
from typing import Tuple
from core.emane.nodes import EmaneNet
from core.errors import CoreError
from core.nodes.base import CoreNode
from core.services.coreservices import CoreService
from core.xml import emanexml
@ -14,37 +13,22 @@ class EmaneTransportService(CoreService):
dependencies: Tuple[str, ...] = ()
dirs: Tuple[str, ...] = ()
configs: Tuple[str, ...] = ("emanetransport.sh",)
startup: Tuple[str, ...] = ("sh %s" % configs[0],)
validate: Tuple[str, ...] = ("pidof %s" % executables[0],)
startup: Tuple[str, ...] = (f"sh {configs[0]}",)
validate: Tuple[str, ...] = (f"pidof {executables[0]}",)
validation_timer: float = 0.5
shutdown: Tuple[str, ...] = ("killall %s" % executables[0],)
shutdown: Tuple[str, ...] = (f"killall {executables[0]}",)
@classmethod
def generate_config(cls, node: CoreNode, filename: str) -> str:
if filename == cls.configs[0]:
transport_commands = []
emane_manager = node.session.emane
cfg = ""
for iface in node.get_ifaces():
try:
network_node = node.session.get_node(iface.net.id, EmaneNet)
config = node.session.emane.get_configs(
network_node.id, network_node.model.name
)
if config and emanexml.is_external(config):
nem_id = network_node.getnemid(iface)
command = (
"emanetransportd -r -l 0 -d ../transportdaemon%s.xml"
% nem_id
)
transport_commands.append(command)
except CoreError:
pass
transport_commands = "\n".join(transport_commands)
return """
emanegentransportxml -o ../ ../platform%s.xml
%s
""" % (
node.id,
transport_commands,
)
else:
raise ValueError
if not isinstance(iface.net, EmaneNet):
continue
emane_net = iface.net
config = emane_manager.get_iface_config(emane_net, iface)
if emanexml.is_external(config):
nem_id = emane_net.getnemid(iface)
cfg += f"emanegentransportxml {iface.name}-platform.xml\n"
cfg += f"emanetransportd -r -l 0 -d transportdaemon{nem_id}.xml\n"
return cfg