Merged PR 379: #2560 - Network_simulator_demo.ipynb cell fixes
## Summary
Some minor changes to the network_simulator_demo jupyter notebook so that all cells run.
I've updated the notebook to use a **very lightly** modified version of the ARCD UC2 network that it has been using.
_I've added a single route into the router_1 route table so that `network.get_node_by_hostname("router_1").route_table.show()` returns something visible. I didn't want to have this within the 'normal' uc2 network. Don't @ me._

Corrected a path typo in `basic_lan_network_example()` so it correctly loads that network config.
## Test process
I've not broken any existing tests, and the notebook now runs with fully populated cells.
## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code
Related work items: #2560
This commit is contained in:
@@ -4,6 +4,7 @@ import yaml
|
||||
|
||||
from primaite import getLogger, PRIMAITE_PATHS
|
||||
from primaite.game.game import PrimaiteGame
|
||||
from primaite.simulator import LogLevel, SIM_OUTPUT
|
||||
from primaite.simulator.network.container import Network
|
||||
from primaite.simulator.network.hardware.nodes.host.computer import Computer
|
||||
from primaite.simulator.network.hardware.nodes.host.host_node import NIC
|
||||
@@ -287,6 +288,20 @@ def arcd_uc2_network() -> Network:
|
||||
return network
|
||||
|
||||
|
||||
def network_simulator_demo_example() -> Network:
|
||||
"""Returns a lightly modified version of the ARCD UC2 Network."""
|
||||
# Ensure that sys_log will be viewable for demo
|
||||
SIM_OUTPUT.sys_log_level = LogLevel.DEBUG
|
||||
SIM_OUTPUT.save_sys_logs = True
|
||||
|
||||
network = arcd_uc2_network()
|
||||
network.get_node_by_hostname("router_1").route_table.add_route(
|
||||
address="192.168.10.0", subnet_mask="255.255.255.0", next_hop_ip_address="192.168.1.2"
|
||||
)
|
||||
|
||||
return network
|
||||
|
||||
|
||||
def _get_example_network(path: str) -> Network:
|
||||
try:
|
||||
with open(path, "r") as file:
|
||||
@@ -308,7 +323,7 @@ def client_server_p2p_network_example() -> Network:
|
||||
|
||||
def basic_lan_network_example() -> Network:
|
||||
"""Get the basic LAN example network."""
|
||||
path = PRIMAITE_PATHS.user_config_path / "example_config" / "basic_network_network_example.yaml"
|
||||
path = PRIMAITE_PATHS.user_config_path / "example_config" / "basic_lan_network_example.yaml"
|
||||
return _get_example_network(path)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user