daemon: updates to support running emane on the fly for a newly connected link

This commit is contained in:
Blake Harnden 2020-07-05 21:56:22 -07:00
parent 5cc4d92760
commit b3a4b1cb10
3 changed files with 14 additions and 4 deletions

View file

@ -252,8 +252,8 @@ class EmaneManager(ModelManager):
"""
with self._emane_node_lock:
if emane_net.id in self._emane_nets:
raise KeyError(
f"non-unique EMANE object id {emane_net.id} for {emane_net}"
raise CoreError(
f"duplicate emane network({emane_net.id}): {emane_net.name}"
)
self._emane_nets[emane_net.id] = emane_net

View file

@ -8,7 +8,13 @@ from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type
from core.emulator.data import InterfaceData, LinkData, LinkOptions
from core.emulator.distributed import DistributedServer
from core.emulator.enumerations import LinkTypes, MessageFlags, NodeTypes, RegisterTlvs
from core.emulator.enumerations import (
EventTypes,
LinkTypes,
MessageFlags,
NodeTypes,
RegisterTlvs,
)
from core.errors import CoreError
from core.nodes.base import CoreNetworkBase, CoreNode
from core.nodes.interface import CoreInterface
@ -203,4 +209,6 @@ class EmaneNet(CoreNetworkBase):
iface.set_mac(iface_data.mac)
for ip in iface_data.get_ips():
iface.add_ip(ip)
if self.session.state == EventTypes.RUNTIME_STATE:
self.session.emane.start_iface(self, iface)
return iface

View file

@ -531,7 +531,7 @@ class Session:
self.set_node_position(node, options)
# add services to needed nodes
if isinstance(node, (CoreNode, PhysicalNode, DockerNode, LxcNode)):
if isinstance(node, (CoreNode, PhysicalNode)):
node.type = options.model
logging.debug("set node type: %s", node.type)
self.services.add_services(node, node.type, options.services)
@ -545,6 +545,8 @@ class Session:
# ensure default emane configuration
if isinstance(node, EmaneNet) and options.emane:
self.emane.set_model_config(_id, options.emane)
if self.state == EventTypes.RUNTIME_STATE:
self.emane.add_node(node)
# set default wlan config if needed
if isinstance(node, WlanNode):
self.mobility.set_model_config(_id, BasicRangeModel.name)