Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle out-of-range VLANs gracefully #357

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"pika >= 1.2.0",
"dataset",
"pymongo > 3.0",
"sdx-pce @ git+https://github.com/atlanticwave-sdx/[email protected].dev4",
"sdx-pce @ git+https://github.com/atlanticwave-sdx/[email protected].dev5",
]

[project.optional-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion sdx_controller/handlers/connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def place_connection(
logger.debug(f"Breakdown sent to LC, status: {status}, code: {code}")
return status, code
except TEError as te_err:
return te_err
# We could probably return te_err.te_code instead of 400,
# but I don't think PCE should use HTTP error codes,
# because that violates abstraction boundaries.
return f"PCE error: {te_err}", 400
except Exception as e:
err = traceback.format_exc().replace("\n", ", ")
logger.error(f"Error when generating/publishing breakdown: {e} - {err}")
Expand Down
4 changes: 4 additions & 0 deletions sdx_controller/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ class TestData:
CONNECTION_REQ_V2_AMLIGHT_ZAOXI = (
REQUESTS_DIR / "test_request-amlight_zaoxi-p2p-v2.json"
)

TOPOLOGY_FILE_AMLIGHT_v2 = TOPOLOGY_DIR / "ampath_v2.json"
TOPOLOGY_FILE_SAX_v2 = TOPOLOGY_DIR / "sax_v2.json"
TOPOLOGY_FILE_ZAOXI_v2 = TOPOLOGY_DIR / "zaoxi_v2.json"
42 changes: 42 additions & 0 deletions sdx_controller/test/test_l2vpn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def __add_the_three_topologies(self):
print(f"Adding topology: {topology.get('id')}")
self.te_manager.add_topology(topology)

def __add_the_three_v2_topologies(self):
"""
A helper to add the three known topologies.
"""
for idx, topology_file in enumerate(
[
TestData.TOPOLOGY_FILE_AMLIGHT_v2,
TestData.TOPOLOGY_FILE_SAX_v2,
TestData.TOPOLOGY_FILE_ZAOXI_v2,
]
):
topology = json.loads(topology_file.read_text())
print(f"Adding topology: {topology.get('id')}")
self.te_manager.add_topology(topology)

def test_delete_connection_with_setup(self):
"""
Test case for delete_connection()
Expand Down Expand Up @@ -569,6 +584,33 @@ def test_z105_getconnections_success(self):

assert len(response.get_json()) != 0

def test_issue_356(self):
"""
See https://github.com/atlanticwave-sdx/sdx-controller/issues/356
"""

self.__add_the_three_v2_topologies()

connection_request = {
"name": "VLAN between AMPATH/300 and TENET/300",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50", "vlan": "30000"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "any"},
],
}

response = self.client.open(
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=json.dumps(connection_request),
content_type="application/json",
)

print(f"POST response body is : {response.data.decode('utf-8')}")
print(f"POST Response JSON is : {response.get_json()}")

self.assertStatus(response, 400)


if __name__ == "__main__":
unittest.main()