Skip to content

Commit

Permalink
Merge pull request #548 from coreemu/develop
Browse files Browse the repository at this point in the history
merging 7.4.0
  • Loading branch information
bharnden authored Jan 11, 2021
2 parents a57b838 + d533083 commit d98a9a5
Show file tree
Hide file tree
Showing 24 changed files with 247 additions and 122 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 2021-01-11 CORE 7.4.0

* Installation
* fixed issue for automated install assuming ID_LIKE is always present in /etc/os-release
* gRPC API
* fixed issue stopping session and not properly going to data collect state
* fixed issue to have start session properly create a directory before configuration state
* core-pygui
* fixed issue handling deletion of wired link to a switch
* avoid saving edge metadata to xml when values are default
* fixed issue editing node mac addresses
* added support for configuring interface names
* fixed issue with potential node names to allow hyphens and remove under bars
* \#531 - fixed issue changing distributed nodes back to local
* core-daemon
* fixed issue to properly handle deleting links from a network to network node
* updated xml to support writing and reading link buffer configurations
* reverted change and removed mac learning from wlan, due to promiscuous like behavior
* fixed issue creating control interfaces when starting services
* fixed deadlock issue when clearing a session using sdt
* \#116 - fixed issue for wlans handling multiple mobility scripts at once
* \#539 - fixed issue in udp tlv api

## 2020-12-02 CORE 7.3.0

* core-daemon
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

# this defines the CORE version number, must be static for AC_INIT
AC_INIT(core, 7.3.0)
AC_INIT(core, 7.4.0)

# autoconf and automake initialization
AC_CONFIG_SRCDIR([netns/version.h.in])
Expand Down
3 changes: 2 additions & 1 deletion daemon/core/api/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def StartSession(

# clear previous state and setup for creation
session.clear()
session.set_state(EventTypes.CONFIGURATION_STATE)
if not os.path.exists(session.session_dir):
os.mkdir(session.session_dir)
session.set_state(EventTypes.CONFIGURATION_STATE)

# location
if request.HasField("location"):
Expand Down Expand Up @@ -315,6 +315,7 @@ def StopSession(
"""
logging.debug("stop session: %s", request)
session = self.get_session(request.session_id, context)
session.data_collect()
session.shutdown()
return core_pb2.StopSessionResponse(result=True)

Expand Down
2 changes: 1 addition & 1 deletion daemon/core/api/tlv/corehandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ def handle(self):
for session_id in sessions:
session = self.server.mainserver.coreemu.sessions.get(session_id)
if session:
logging.debug("session handling message: %s", session.session_id)
logging.debug("session handling message: %s", session.id)
self.session = session
self.handle_message(message)
self.broadcast(message)
Expand Down
4 changes: 1 addition & 3 deletions daemon/core/emane/emanemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from core.emulator.enumerations import ConfigDataTypes
from core.errors import CoreError
from core.location.mobility import WirelessModel
from core.nodes.base import CoreNode
from core.nodes.interface import CoreInterface
from core.xml import emanexml

Expand Down Expand Up @@ -119,13 +118,12 @@ def post_startup(self) -> None:
"""
logging.debug("emane model(%s) has no post setup tasks", self.name)

def update(self, moved: List[CoreNode], moved_ifaces: List[CoreInterface]) -> None:
def update(self, moved_ifaces: List[CoreInterface]) -> None:
"""
Invoked from MobilityModel when nodes are moved; this causes
emane location events to be generated for the nodes in the moved
list, making EmaneModels compatible with Ns2ScriptedMobility.
:param moved: moved nodes
:param moved_ifaces: interfaces that were moved
:return: nothing
"""
Expand Down
1 change: 1 addition & 0 deletions daemon/core/emulator/coreemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def delete_session(self, _id: int) -> bool:
result = False
if session:
logging.info("shutting session down: %s", _id)
session.data_collect()
session.shutdown()
result = True
else:
Expand Down
3 changes: 3 additions & 0 deletions daemon/core/emulator/enumerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class EventTypes(Enum):
def should_start(self) -> bool:
return self.value > self.DEFINITION_STATE.value

def already_collected(self) -> bool:
return self.value >= self.DATACOLLECT_STATE.value


class ExceptionLevels(Enum):
"""
Expand Down
59 changes: 40 additions & 19 deletions daemon/core/emulator/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import threading
import time
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.configservice.manager import ConfigServiceManager
Expand Down Expand Up @@ -369,6 +369,19 @@ def delete_link(
node1.delete_iface(iface1_id)
elif isinstance(node2, CoreNodeBase) and isinstance(node1, CoreNetworkBase):
node2.delete_iface(iface2_id)
elif isinstance(node1, CoreNetworkBase) and isinstance(
node2, CoreNetworkBase
):
for iface in node1.get_ifaces(control=False):
if iface.othernet == node2:
node1.detach(iface)
iface.shutdown()
break
for iface in node2.get_ifaces(control=False):
if iface.othernet == node1:
node2.detach(iface)
iface.shutdown()
break
self.sdt.delete_link(node1_id, node2_id)

def update_link(
Expand Down Expand Up @@ -558,11 +571,11 @@ def add_node(
if isinstance(node, WlanNode):
self.mobility.set_model_config(_id, BasicRangeModel.name)

# boot nodes after runtime, CoreNodes, Physical, and RJ45 are all nodes
is_boot_node = isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node)
# boot nodes after runtime CoreNodes and PhysicalNodes
is_boot_node = isinstance(node, (CoreNode, PhysicalNode))
if self.state == EventTypes.RUNTIME_STATE and is_boot_node:
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.sdt.add_node(node)
Expand Down Expand Up @@ -757,10 +770,11 @@ def shutdown(self) -> None:
"""
Shutdown all session nodes and remove the session directory.
"""
if self.state == EventTypes.SHUTDOWN_STATE:
logging.info("session(%s) state(%s) already shutdown", self.id, self.state)
return
logging.info("session(%s) state(%s) shutting down", self.id, self.state)
if self.state != EventTypes.SHUTDOWN_STATE:
self.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)
self.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)
self.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)
# clear out current core session
self.clear()
# shutdown sdt
Expand Down Expand Up @@ -1115,13 +1129,16 @@ def delete_nodes(self) -> None:
"""
Clear the nodes dictionary, and call shutdown for each node.
"""
nodes_ids = []
with self.nodes_lock:
funcs = []
while self.nodes:
_, node = self.nodes.popitem()
self.sdt.delete_node(node.id)
nodes_ids.append(node.id)
funcs.append((node.shutdown, [], {}))
utils.threadpool(funcs)
for node_id in nodes_ids:
self.sdt.delete_node(node_id)

def write_nodes(self) -> None:
"""
Expand Down Expand Up @@ -1245,6 +1262,14 @@ def data_collect(self) -> None:
:return: nothing
"""
if self.state.already_collected():
logging.info(
"session(%s) state(%s) already data collected", self.id, self.state
)
return
logging.info("session(%s) state(%s) data collection", self.id, self.state)
self.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)

# stop event loop
self.event_loop.stop()

Expand All @@ -1266,10 +1291,8 @@ def data_collect(self) -> None:
self.update_control_iface_hosts(remove=True)

# remove all four possible control networks
self.add_remove_control_net(0, remove=True)
self.add_remove_control_net(1, remove=True)
self.add_remove_control_net(2, remove=True)
self.add_remove_control_net(3, remove=True)
for i in range(4):
self.add_remove_control_net(i, remove=True)

def short_session_id(self) -> str:
"""
Expand All @@ -1290,7 +1313,6 @@ def boot_node(self, node: CoreNode) -> None:
:return: nothing
"""
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)
node.start_config_services()

Expand All @@ -1305,11 +1327,10 @@ def boot_nodes(self) -> List[Exception]:
with self.nodes_lock:
funcs = []
start = time.monotonic()
for _id in self.nodes:
node = self.nodes[_id]
if isinstance(node, CoreNodeBase) and not isinstance(node, Rj45Node):
args = (node,)
funcs.append((self.boot_node, args, {}))
for node in self.nodes.values():
if isinstance(node, (CoreNode, PhysicalNode)):
self.add_remove_control_iface(node, remove=False)
funcs.append((self.boot_node, (node,), {}))
results, exceptions = utils.threadpool(funcs)
total = time.monotonic() - start
logging.debug("boot run time: %s", total)
Expand Down Expand Up @@ -1457,7 +1478,7 @@ def add_remove_control_net(

def add_remove_control_iface(
self,
node: CoreNode,
node: Union[CoreNode, PhysicalNode],
net_index: int = 0,
remove: bool = False,
conf_required: bool = True,
Expand Down
2 changes: 2 additions & 0 deletions daemon/core/gui/coreclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ def set_metadata(self) -> None:
# create edges config
edges_config = []
for edge in self.links.values():
if not edge.is_customized():
continue
edge_config = dict(token=edge.token, width=edge.width, color=edge.color)
edges_config.append(edge_config)
edges_config = json.dumps(edges_config)
Expand Down
Loading

0 comments on commit d98a9a5

Please sign in to comment.