Merged PR 376: 2457 - Remove Hardcoding from Links

## Summary
This PR removes the hardcoding of Link bandwidth, and makes it possible to be configured via the network yaml definitions.
Link bandwidth will still default to 100 if this is not present, to prevent breaking all previous defined networks.

## Test process
All tests continue to pass.
`basic_network_config.yaml` now provides a non-default link bandwidth which is confirmed within unit tests.

## 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
- [ ] written/updated **design docs** if this PR implements new functionality
- [] 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: #2457
This commit is contained in:
Charlie Crane
2024-05-22 11:35:48 +00:00
12 changed files with 38 additions and 15 deletions

View File

@@ -43,3 +43,6 @@ def test_basic_config():
# client 3 should not be online
client_3: Computer = network.get_node_by_hostname("client_3")
assert client_3.operating_state == NodeOperatingState.OFF
for link in network.links:
assert network.links[link].bandwidth == 200

View File

@@ -49,12 +49,12 @@ def web_client_web_server_database(example_network) -> Tuple[Network, Computer,
db_server_nic = db_server.network_interfaces[next(iter(db_server.network_interfaces))]
# Connect Computer and Server
link_computer_server = Link(endpoint_a=computer_nic, endpoint_b=server_nic)
link_computer_server = Link(endpoint_a=computer_nic, endpoint_b=server_nic, bandwidth=100)
# Should be linked
assert link_computer_server.is_up
# Connect database server and web server
link_server_db = Link(endpoint_a=server_nic, endpoint_b=db_server_nic)
link_server_db = Link(endpoint_a=server_nic, endpoint_b=db_server_nic, bandwidth=100)
# Should be linked
assert link_computer_server.is_up
assert link_server_db.is_up