From 8d15b2a2d7a25671efd4f4c781173666cc0948e1 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 30 Jul 2024 06:53:56 -0700 Subject: [PATCH 1/6] emane: fixed issue with tdma model code --- daemon/core/emane/models/tdma.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/core/emane/models/tdma.py b/daemon/core/emane/models/tdma.py index 100e960d..6d2d3873 100644 --- a/daemon/core/emane/models/tdma.py +++ b/daemon/core/emane/models/tdma.py @@ -56,7 +56,7 @@ def post_startup(self, iface: CoreInterface) -> None: if not nem_id: logger.error("could not find nem for interface") return - service = self.session.emane.nem_service.get(nem_id) + service = self.session.emane.event_manager.get_service(nem_id) if service: device = service.device logger.info( From c0c3cf5f5eb746e1ab1845e4e278c854dd397957 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 30 Jul 2024 07:00:47 -0700 Subject: [PATCH 2/6] docs: fixed missing sudo in ubuntu install example --- docs/install_ubuntu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install_ubuntu.md b/docs/install_ubuntu.md index 3fe36431..c1dc28c4 100644 --- a/docs/install_ubuntu.md +++ b/docs/install_ubuntu.md @@ -31,7 +31,7 @@ sudo apt-get install -y \ # install ospf mdr cd ~/Documents -apt-get install -y \ +sudo apt-get install -y \ automake \ gawk \ g++ \ From 44ff508e3f2c72fd0741f21eefad330a62f21c52 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Tue, 30 Jul 2024 07:22:17 -0700 Subject: [PATCH 3/6] docs: updated tutorial documentation to refer to absolute paths of the installed CORE files to be more explicit --- docs/tutorials/setup.md | 14 +++++++++++++- docs/tutorials/tutorial1.md | 8 ++++---- docs/tutorials/tutorial2.md | 6 ++++-- docs/tutorials/tutorial3.md | 12 ++++++++---- docs/tutorials/tutorial4.md | 9 ++++++--- docs/tutorials/tutorial5.md | 9 ++++++--- docs/tutorials/tutorial6.md | 12 ++++++++---- docs/tutorials/tutorial7.md | 8 ++++---- 8 files changed, 53 insertions(+), 25 deletions(-) diff --git a/docs/tutorials/setup.md b/docs/tutorials/setup.md index 2b7877c9..537e9d52 100644 --- a/docs/tutorials/setup.md +++ b/docs/tutorials/setup.md @@ -4,6 +4,17 @@ We assume the prior installation of CORE, using a virtual environment. +```shell +# location of all core files +/opt/core + +# location of the virtual environment +/opt/core/venv + +# convenience command for using core's python virtual environment +core-python +``` + ## Setup for Chat App There is a simple TCP chat app provided as example software to use and run within @@ -15,6 +26,7 @@ The following will install chatapp and its scripts into **/usr/local**, which yo may need to add to PATH within node to be able to use command directly. ``` shell +cd /opt/core/share/tutorials/chatapp sudo python3 -m pip install . ``` @@ -66,7 +78,7 @@ optional arguments: ``` shell custom_services_dir = ``` -2. Then you will need to copy/move **chatapp/chatapp_service.py** to the directory +2. Then you will need to copy/move **/opt/core/share/tutorials/chatapp/chatapp_service.py** to the directory configured above 3. Then you will need to restart the **core-daemon** to pick up this new service 4. Now the service will be an available option under the group **ChatApp** with diff --git a/docs/tutorials/tutorial1.md b/docs/tutorials/tutorial1.md index 7e275fea..fbc2951d 100644 --- a/docs/tutorials/tutorial1.md +++ b/docs/tutorials/tutorial1.md @@ -14,11 +14,11 @@ scenario in CORE. Below is the list of files used for this tutorial. * 2 node wired scenario - * scenario.xml - * scenario.py + * /opt/core/share/tutorials/tutorial1/scenario.xml + * /opt/core/share/tutorials/tutorial1/scenario.py * 2 node wired scenario, with **n1** running the "Chat App Server" service - * scenario_service.xml - * scenario_service.py + * /opt/core/share/tutorials/tutorial1/scenario_service.xml + * /opt/core/share/tutorials/tutorial1/scenario_service.py ## Running this Tutorial diff --git a/docs/tutorials/tutorial2.md b/docs/tutorials/tutorial2.md index d319f383..801e47bb 100644 --- a/docs/tutorials/tutorial2.md +++ b/docs/tutorials/tutorial2.md @@ -10,8 +10,10 @@ send a simple message and the server will log receipt of the message. Below is the list of files used for this tutorial. -* scenario.xml - 3 node CORE xml scenario file (wireless) -* scenario.py - 3 node CORE gRPC python script (wireless) +* 3 node CORE xml scenario file (wireless) + * /opt/core/share/tutorials/tutorial2/scenario.xml +* 3 node CORE gRPC python script (wireless) + * /opt/core/share/tutorials/tutorial2/scenario.py ## Running with the XML Scenario File diff --git a/docs/tutorials/tutorial3.md b/docs/tutorials/tutorial3.md index 720ef0ed..b9f5f049 100644 --- a/docs/tutorials/tutorial3.md +++ b/docs/tutorials/tutorial3.md @@ -9,10 +9,14 @@ Mobility can be provided from a NS2 file or by including mobility commands in a Below is the list of files used for this tutorial. -* movements1.txt - a NS2 mobility input file -* scenario.xml - 3 node CORE xml scenario file (wireless) -* scenario.py - 3 node CORE gRPC python script (wireless) -* printout.py - event listener +* NS2 mobility input file + * /opt/core/share/tutorials/tutorial3/movements1.txt +* 3 node CORE xml scenario file (wireless) + * /opt/core/share/tutorials/tutorial3/scenario.xml +* 3 node CORE gRPC python script (wireless) + * /opt/core/share/tutorials/tutorial3/scenario.py +* event listener + * /opt/core/share/tutorials/tutorial3/printout.py ## Running with XML file using NS2 Movement diff --git a/docs/tutorials/tutorial4.md b/docs/tutorials/tutorial4.md index 77ac1c94..65ef062f 100644 --- a/docs/tutorials/tutorial4.md +++ b/docs/tutorials/tutorial4.md @@ -19,9 +19,12 @@ A directory is used for containing your tests. Within this directory we need a **conftest.py**, which pytest will pick up to help define and provide test fixtures, which will be leveraged within our tests. -* tests - * conftest.py - file used by pytest to define fixtures, which can be shared across tests - * test_ping.py - defines test classes/functions to run +* tests directory + * /opt/core/share/tutorials/tutorial4/tests +* file used by pytest to define fixtures, which can be shared across tests + * /opt/core/share/tutorials/tutorial4/conftest.py +* defines test classes/functions to run + * /opt/core/share/tutorials/tutorial4/test_ping.py ## Test Fixtures diff --git a/docs/tutorials/tutorial5.md b/docs/tutorials/tutorial5.md index b6bf8fac..20696265 100644 --- a/docs/tutorials/tutorial5.md +++ b/docs/tutorials/tutorial5.md @@ -8,9 +8,12 @@ This tutorial will cover connecting CORE VM to a Windows host machine using a RJ Below is the list of files used for this tutorial. -* scenario.xml - the scenario with RJ45 unassigned -* scenario.py- grpc script to create the RJ45 in simple CORE scenario -* client_for_windows.py - chat app client modified for windows +* the scenario with RJ45 unassigned + * /opt/core/share/tutorials/tutorial5/scenario.xml +* grpc script to create the RJ45 in simple CORE scenario + * /opt/core/share/tutorials/tutorial5/scenario.py +* chat app client modified for windows + * /opt/core/share/tutorials/tutorial5/client_for_windows.py ## Running with the Saved XML File diff --git a/docs/tutorials/tutorial6.md b/docs/tutorials/tutorial6.md index a10c6d3a..b0b264cb 100644 --- a/docs/tutorials/tutorial6.md +++ b/docs/tutorials/tutorial6.md @@ -8,10 +8,14 @@ This tutorial will cover changing the node icons, changing the background, and c Below is the list of files used for this tutorial. -* drone.png - icon for a drone -* demo.py - a mobility script for a node -* terrain.png - a background -* completed-scenario.xml - the scenario after making all changes below +* a mobility script for a node + * /opt/core/share/tutorials/tutorial6/demo.py +* drone icon + * /opt/core/share/tutorials/tutorial6/drone.png +* background image + * /opt/core/share/tutorials/tutorial6/terrain.png +* the scenario after making all changes below + * /opt/core/share/tutorials/tutorial6/completed-scenario.xml ## Running this Tutorial diff --git a/docs/tutorials/tutorial7.md b/docs/tutorials/tutorial7.md index 38d855ea..b7248813 100644 --- a/docs/tutorials/tutorial7.md +++ b/docs/tutorials/tutorial7.md @@ -19,11 +19,11 @@ For more detailed information on EMANE see the following: Below is a list of the files used for this tutorial. * 2 node EMANE ieee80211abg scenario - * scenario.xml - * scenario.py + * /opt/core/share/tutorials/tutorial7/scenario.xml + * /opt/core/share/tutorials/tutorial7/scenario.py * 2 node EMANE ieee80211abg scenario, with **n2** running the "Chat App Server" service - * scenario_service.xml - * scenario_service.py + * /opt/core/share/tutorials/tutorial7/scenario_service.xml + * /opt/core/share/tutorials/tutorial7/scenario_service.py ## Running this Tutorial From d9013ab5f0f73498ce94e7b0e9fd9973644d413b Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:27:44 -0700 Subject: [PATCH 4/6] updates to service documentation validation mode to use actual variable examples --- docs/services.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/services.md b/docs/services.md index 474f4122..e1aa9484 100644 --- a/docs/services.md +++ b/docs/services.md @@ -150,7 +150,7 @@ class ExampleService(CoreService): validate: list[str] = [] # commands to run to stop this service shutdown: list[str] = [] - # validation mode, blocking, non-blocking, and timer + # validation mode BLOCKING, NON_BLOCKING, and TIMER validation_mode: ServiceMode = ServiceMode.BLOCKING # configurable values that this service can use, for file generation default_configs: list[Configuration] = [ @@ -191,9 +191,9 @@ class ExampleService(CoreService): Validation modes are used to determine if a service has started up successfully. -* blocking - startup commands are expected to run til completion and return 0 exit code -* non-blocking - startup commands are ran, but do not wait for completion -* timer - startup commands are ran, and an arbitrary amount of time is waited to consider started +* `BLOCKING` - startup commands are expected to run til completion and return 0 exit code +* `NON_BLOCKING` - startup commands are ran, but do not wait for completion +* `TIMER` - startup commands are ran, and an arbitrary amount of time is waited to consider started #### Shadow Directories From 33f07dd23cbcec8e70296eb0f50e51dfd64d75a3 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:33:32 -0700 Subject: [PATCH 5/6] updated incorrect documentation for grpc client open xml --- daemon/core/api/grpc/client.py | 2 +- daemon/core/emulator/session.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index 2d8adae4..1d25b4ca 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -830,7 +830,7 @@ def open_xml(self, file_path: Path, start: bool = False) -> tuple[bool, int]: Load a local scenario XML file to open as a new session. :param file_path: path of scenario XML file - :param start: tuple of result and session id when successful + :param start: instantiate session if true, false for a definition state :return: tuple of result and session id """ with file_path.open("r") as f: diff --git a/daemon/core/emulator/session.py b/daemon/core/emulator/session.py index 1f959c41..54a17198 100644 --- a/daemon/core/emulator/session.py +++ b/daemon/core/emulator/session.py @@ -528,7 +528,7 @@ def open_xml(self, file_path: Path, start: bool = False) -> None: Import a session from the EmulationScript XML format. :param file_path: xml file to load session from - :param start: instantiate session if true, false otherwise + :param start: instantiate session if true, false for a definition state :return: nothing """ logger.info("opening xml: %s", file_path) From a1464a2e75a0a09c269f80b8828be3f9cb8951a8 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:47:47 -0700 Subject: [PATCH 6/6] daemon: fixed service run validation to avoid crashing when more than one startup command exists --- daemon/core/services/base.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/core/services/base.py b/daemon/core/services/base.py index d37d6bcc..e2c7606c 100644 --- a/daemon/core/services/base.py +++ b/daemon/core/services/base.py @@ -369,13 +369,11 @@ def run_validation(self) -> None: """ start = time.monotonic() cmds = self.validate[:] - index = 0 while cmds: - cmd = cmds[index] + cmd = cmds[0] try: self.node.cmd(cmd, shell=True) - del cmds[index] - index += 1 + del cmds[0] except CoreCommandError: logger.debug( f"node({self.node.name}) service({self.name}) "