Merge branch 'develop' into feature/pygui-multi-canvas
This commit is contained in:
commit
8eada3d754
4 changed files with 29 additions and 17 deletions
|
@ -2029,7 +2029,7 @@ class CoreUdpHandler(CoreHandler):
|
||||||
for session_id in sessions:
|
for session_id in sessions:
|
||||||
session = self.server.mainserver.coreemu.sessions.get(session_id)
|
session = self.server.mainserver.coreemu.sessions.get(session_id)
|
||||||
if session:
|
if session:
|
||||||
logging.debug("session handling message: %s", session.session_id)
|
logging.debug("session handling message: %s", session.id)
|
||||||
self.session = session
|
self.session = session
|
||||||
self.handle_message(message)
|
self.handle_message(message)
|
||||||
self.broadcast(message)
|
self.broadcast(message)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, TypeVar
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
from core import constants, utils
|
from core import constants, utils
|
||||||
from core.configservice.manager import ConfigServiceManager
|
from core.configservice.manager import ConfigServiceManager
|
||||||
|
@ -571,11 +571,11 @@ class Session:
|
||||||
if isinstance(node, WlanNode):
|
if isinstance(node, WlanNode):
|
||||||
self.mobility.set_model_config(_id, BasicRangeModel.name)
|
self.mobility.set_model_config(_id, BasicRangeModel.name)
|
||||||
|
|
||||||
# boot nodes after runtime, CoreNodes, Physical, and RJ45 are all nodes
|
# boot nodes after runtime CoreNodes and PhysicalNodes
|
||||||
is_boot_node = isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node)
|
is_boot_node = isinstance(node, (CoreNode, PhysicalNode))
|
||||||
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
|
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
|
||||||
self.write_nodes()
|
self.write_nodes()
|
||||||
self.add_remove_control_iface(node=node, remove=False)
|
self.add_remove_control_iface(node, remove=False)
|
||||||
self.services.boot_services(node)
|
self.services.boot_services(node)
|
||||||
|
|
||||||
self.sdt.add_node(node)
|
self.sdt.add_node(node)
|
||||||
|
@ -1310,7 +1310,6 @@ class Session:
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logging.info("booting node(%s): %s", node.name, [x.name for x in node.services])
|
logging.info("booting node(%s): %s", node.name, [x.name for x in node.services])
|
||||||
self.add_remove_control_iface(node=node, remove=False)
|
|
||||||
self.services.boot_services(node)
|
self.services.boot_services(node)
|
||||||
node.start_config_services()
|
node.start_config_services()
|
||||||
|
|
||||||
|
@ -1325,11 +1324,10 @@ class Session:
|
||||||
with self.nodes_lock:
|
with self.nodes_lock:
|
||||||
funcs = []
|
funcs = []
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
for _id in self.nodes:
|
for node in self.nodes.values():
|
||||||
node = self.nodes[_id]
|
if isinstance(node, (CoreNode, PhysicalNode)):
|
||||||
if isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node):
|
self.add_remove_control_iface(node, remove=False)
|
||||||
args = (node,)
|
funcs.append((self.boot_node, (node,), {}))
|
||||||
funcs.append((self.boot_node, args, {}))
|
|
||||||
results, exceptions = utils.threadpool(funcs)
|
results, exceptions = utils.threadpool(funcs)
|
||||||
total = time.monotonic() - start
|
total = time.monotonic() - start
|
||||||
logging.debug("boot run time: %s", total)
|
logging.debug("boot run time: %s", total)
|
||||||
|
@ -1477,7 +1475,7 @@ class Session:
|
||||||
|
|
||||||
def add_remove_control_iface(
|
def add_remove_control_iface(
|
||||||
self,
|
self,
|
||||||
node: CoreNode,
|
node: Union[CoreNode, PhysicalNode],
|
||||||
net_index: int = 0,
|
net_index: int = 0,
|
||||||
remove: bool = False,
|
remove: bool = False,
|
||||||
conf_required: bool = True,
|
conf_required: bool = True,
|
||||||
|
|
|
@ -837,7 +837,12 @@ class CoreNode(CoreNodeBase):
|
||||||
if net.has_custom_iface:
|
if net.has_custom_iface:
|
||||||
return net.custom_iface(self, iface_data)
|
return net.custom_iface(self, iface_data)
|
||||||
else:
|
else:
|
||||||
iface_id = self.newveth(iface_data.id, iface_data.name)
|
iface_id = iface_data.id
|
||||||
|
if iface_id is not None and iface_id in self.ifaces:
|
||||||
|
raise CoreError(
|
||||||
|
f"node({self.name}) already has interface({iface_id})"
|
||||||
|
)
|
||||||
|
iface_id = self.newveth(iface_id, iface_data.name)
|
||||||
self.attachnet(iface_id, net)
|
self.attachnet(iface_id, net)
|
||||||
if iface_data.mac:
|
if iface_data.mac:
|
||||||
self.set_mac(iface_id, iface_data.mac)
|
self.set_mac(iface_id, iface_data.mac)
|
||||||
|
|
|
@ -266,7 +266,9 @@ class Rj45Node(CoreNodeBase):
|
||||||
will run on, default is None for localhost
|
will run on, default is None for localhost
|
||||||
"""
|
"""
|
||||||
super().__init__(session, _id, name, server)
|
super().__init__(session, _id, name, server)
|
||||||
self.iface = CoreInterface(session, self, name, name, mtu, server)
|
self.iface: CoreInterface = CoreInterface(
|
||||||
|
session, self, name, name, mtu, server
|
||||||
|
)
|
||||||
self.iface.transport_type = TransportType.RAW
|
self.iface.transport_type = TransportType.RAW
|
||||||
self.lock: threading.RLock = threading.RLock()
|
self.lock: threading.RLock = threading.RLock()
|
||||||
self.iface_id: Optional[int] = None
|
self.iface_id: Optional[int] = None
|
||||||
|
@ -335,11 +337,12 @@ class Rj45Node(CoreNodeBase):
|
||||||
if iface_id is None:
|
if iface_id is None:
|
||||||
iface_id = 0
|
iface_id = 0
|
||||||
if self.iface.net is not None:
|
if self.iface.net is not None:
|
||||||
raise CoreError("RJ45 nodes support at most 1 network interface")
|
raise CoreError(
|
||||||
|
f"RJ45({self.name}) nodes support at most 1 network interface"
|
||||||
|
)
|
||||||
self.ifaces[iface_id] = self.iface
|
self.ifaces[iface_id] = self.iface
|
||||||
self.iface_id = iface_id
|
self.iface_id = iface_id
|
||||||
if net is not None:
|
self.iface.attachnet(net)
|
||||||
self.iface.attachnet(net)
|
|
||||||
for ip in iface_data.get_ips():
|
for ip in iface_data.get_ips():
|
||||||
self.add_ip(ip)
|
self.add_ip(ip)
|
||||||
return self.iface
|
return self.iface
|
||||||
|
@ -353,6 +356,12 @@ class Rj45Node(CoreNodeBase):
|
||||||
"""
|
"""
|
||||||
self.get_iface(iface_id)
|
self.get_iface(iface_id)
|
||||||
self.ifaces.pop(iface_id)
|
self.ifaces.pop(iface_id)
|
||||||
|
if self.iface.net is None:
|
||||||
|
raise CoreError(
|
||||||
|
f"RJ45({self.name}) is not currently connected to a network"
|
||||||
|
)
|
||||||
|
self.iface.detachnet()
|
||||||
|
self.iface.net = None
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
def get_iface(self, iface_id: int) -> CoreInterface:
|
def get_iface(self, iface_id: int) -> CoreInterface:
|
||||||
|
|
Loading…
Add table
Reference in a new issue