Skip to content

Commit

Permalink
Merge pull request #512 from coreemu/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bharnden authored Sep 29, 2020
2 parents 16495c9 + 3d3e227 commit 56e98f4
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 153 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2020-09-29 CORE 7.2.1

* core-daemon
* fixed issue where shutting down sessions may not have removed session directories
* fixed issue with multiple emane interfaces on the same node not getting the right configuration
* Installation
* updated automated install to be a bit more robust for alternative distros
* added force install type to try and leverage a redhat/debian like install
* locked ospf mdr version installed to older commit to avoid issues with multiple interfaces on same node

## 2020-09-15 CORE 7.2.0

* Installation
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.2.0)
AC_INIT(core, 7.2.1)

# autoconf and automake initialization
AC_CONFIG_SRCDIR([netns/version.h.in])
Expand Down
5 changes: 1 addition & 4 deletions daemon/core/api/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,7 @@ def StopSession(
"""
logging.debug("stop session: %s", request)
session = self.get_session(request.session_id, context)
session.data_collect()
session.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)
session.clear()
session.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)
session.shutdown()
return core_pb2.StopSessionResponse(result=True)

def CreateSession(
Expand Down
5 changes: 5 additions & 0 deletions daemon/core/api/tlv/corehandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ def handle_node_message(self, message):
elif message.flags & MessageFlags.DELETE.value:
with self._shutdown_lock:
result = self.session.delete_node(node_id)
if result and self.session.get_node_count() == 0:
self.session.set_state(EventTypes.SHUTDOWN_STATE)
self.session.delete_nodes()
self.session.distributed.shutdown()
self.session.sdt.shutdown()

# if we deleted a node broadcast out its removal
if result and message.flags & MessageFlags.STRING.value:
Expand Down
14 changes: 8 additions & 6 deletions daemon/core/emane/emanemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class EmaneState(Enum):

@dataclass
class StartData:
emane_net: EmaneNet
node: CoreNodeBase
ifaces: List[CoreInterface] = field(default_factory=list)

Expand Down Expand Up @@ -370,9 +369,7 @@ def get_start_data(self) -> List[StartData]:
iface.name,
)
continue
start_node = node_map.setdefault(
iface.node, StartData(emane_net, iface.node)
)
start_node = node_map.setdefault(iface.node, StartData(iface.node))
start_node.ifaces.append(iface)
start_nodes = sorted(node_map.values(), key=lambda x: x.node.id)
for start_node in start_nodes:
Expand All @@ -386,7 +383,7 @@ def start_node(self, data: StartData) -> None:
emanexml.build_platform_xml(self, control_net, data)
self.start_daemon(data.node)
for iface in data.ifaces:
self.install_iface(data.emane_net, iface)
self.install_iface(iface)

def set_nem(self, nem_id: int, iface: CoreInterface) -> None:
if nem_id in self.nems_to_ifaces:
Expand Down Expand Up @@ -606,7 +603,12 @@ def start_daemon(self, node: CoreNodeBase) -> None:
node.host_cmd(emanecmd, cwd=path)
logging.info("node(%s) host emane daemon running: %s", node.name, emanecmd)

def install_iface(self, emane_net: EmaneNet, iface: CoreInterface) -> None:
def install_iface(self, iface: CoreInterface) -> None:
emane_net = iface.net
if not isinstance(emane_net, EmaneNet):
raise CoreError(
f"emane interface not connected to emane net: {emane_net.name}"
)
config = self.get_iface_config(emane_net, iface)
external = config.get("external", "0")
if isinstance(iface, TunTap) and external == "0":
Expand Down
31 changes: 3 additions & 28 deletions daemon/core/emulator/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,23 +756,18 @@ def shutdown(self) -> None:
"""
Shutdown all session nodes and remove the session directory.
"""
if self.state == EventTypes.SHUTDOWN_STATE:
return
logging.info("session(%s) state(%s) shutting down", self.id, self.state)
self.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)
self.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)

if self.state != EventTypes.SHUTDOWN_STATE:
self.set_state(EventTypes.DATACOLLECT_STATE, send_event=True)
self.set_state(EventTypes.SHUTDOWN_STATE, send_event=True)
# clear out current core session
self.clear()

# shutdown sdt
self.sdt.shutdown()

# remove this sessions working directory
preserve = self.options.get_config("preservedir") == "1"
if not preserve:
shutil.rmtree(self.session_dir, ignore_errors=True)

# call session shutdown handlers
for handler in self.shutdown_handlers:
handler(self)
Expand Down Expand Up @@ -1116,7 +1111,6 @@ def delete_node(self, _id: int) -> bool:
if node:
node.shutdown()
self.sdt.delete_node(_id)
self.check_shutdown()
return node is not None

def delete_nodes(self) -> None:
Expand Down Expand Up @@ -1279,25 +1273,6 @@ def data_collect(self) -> None:
self.add_remove_control_net(2, remove=True)
self.add_remove_control_net(3, remove=True)

def check_shutdown(self) -> bool:
"""
Check if we have entered the shutdown state, when no running nodes
and links remain.
:return: True if should shutdown, False otherwise
"""
node_count = self.get_node_count()
logging.debug(
"session(%s) checking shutdown: %s nodes remaining", self.id, node_count
)
shutdown = False
if node_count == 0:
shutdown = True
self.set_state(EventTypes.SHUTDOWN_STATE)
# clearing sdt saved data here for legacy gui
self.sdt.shutdown()
return shutdown

def short_session_id(self) -> str:
"""
Return a shorter version of the session ID, appropriate for
Expand Down
11 changes: 7 additions & 4 deletions daemon/core/xml/emanexml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from core import utils
from core.config import Configuration
from core.emane.nodes import EmaneNet
from core.emulator.distributed import DistributedServer
from core.errors import CoreError
from core.nodes.base import CoreNode, CoreNodeBase
Expand Down Expand Up @@ -166,8 +167,12 @@ def build_platform_xml(
add_param(platform_element, name, value)

# create nem xml entries for all interfaces
emane_net = data.emane_net
for iface in data.ifaces:
emane_net = iface.net
if not isinstance(emane_net, EmaneNet):
raise CoreError(
f"emane interface not connected to emane net: {emane_net.name}"
)
nem_id = emane_manager.next_nem_id()
emane_manager.set_nem(nem_id, iface)
emane_manager.write_nem(iface, nem_id)
Expand All @@ -180,9 +185,7 @@ def build_platform_xml(
"nem", id=str(nem_id), name=iface.localname, definition=nem_definition
)

# check if this is an external transport, get default config if an interface
# specific one does not exist
config = emane_manager.get_iface_config(emane_net, iface)
# check if this is an external transport
if is_external(config):
nem_element.set("transport", "external")
platform_endpoint = "platformendpoint"
Expand Down
2 changes: 1 addition & 1 deletion daemon/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "core"
version = "7.2.0"
version = "7.2.1"
description = "CORE Common Open Research Emulator"
authors = ["Boeing Research and Technology"]
license = "BSD-2-Clause"
Expand Down
Loading

0 comments on commit 56e98f4

Please sign in to comment.