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 :return: net, node, or interface model configuration
""" """
model_name = emane_net.model.name 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 # 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 # note here that using iface.node.id as key allows for only one type
# of each model per node; # of each model per node;
@ -587,26 +583,18 @@ class EmaneManager(ModelManager):
""" """
Kill the appropriate EMANE daemons. 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_emaned = "killall -q emane"
kill_transortd = "killall -q emanetransportd"
stop_emane_on_host = False stop_emane_on_host = False
for node in self.getnodes(): for node in self.getnodes():
if isinstance(node, Rj45Node): if isinstance(node, Rj45Node):
stop_emane_on_host = True stop_emane_on_host = True
continue continue
if node.up: if node.up:
node.cmd(kill_emaned, wait=False) node.cmd(kill_emaned, wait=False)
# TODO: RJ45 node
if stop_emane_on_host: if stop_emane_on_host:
try: try:
utils.cmd(kill_emaned) utils.cmd(kill_emaned, wait=False)
utils.cmd(kill_transortd)
self.session.distributed.execute(lambda x: x.remote_cmd(kill_emaned)) self.session.distributed.execute(lambda x: x.remote_cmd(kill_emaned))
self.session.distributed.execute(lambda x: x.remote_cmd(kill_transortd))
except CoreCommandError: except CoreCommandError:
logging.exception("error shutting down emane daemons") logging.exception("error shutting down emane daemons")

View file

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