Skip to content

Commit

Permalink
Find common inter-domain VLAN ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
sajith committed Nov 9, 2024
1 parent 4b74b85 commit e7c7715
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/sdx_pce/topology/temanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,47 @@ def _find_common_vlan_on_link(
downstream_vlan_table.keys()
)

self._logger.info(
f"Looking for common VLANS for connection_request: {connection_request}"
)

# TODO: shouldn't we update VLAN allocation tables here?

# TODO: This is a work-around to find out if a VLAN range was
# specified in the connection request, and then handle it
# accordingly. This code could probably be simplified if we
# use a "proper" data structure to represent the original
# connection request internally.
if connection_request and isinstance(connection_request, dict):
ingress_vlans_str = connection_request.get("ingress_port").get("vlan_range")
egress_vlans_str = connection_request.get("egress_port").get("vlan_range")

self._logger.info(
f"Found ingress_vlans: {ingress_vlans_str}, "
f"egress_vlans: {egress_vlans_str}"
)

if self._tag_is_vlan_range(ingress_vlans_str) and self._tag_is_vlan_range(
egress_vlans_str
):
start, end = map(int, ingress_vlans_str.split(":"))
vlans = list(range(start, end + 1))

for vlan in vlans:
if upstream_vlan_table[vlan] is not UNUSED_VLAN:
raise Exception(
f"Upstream VLAN {vlan} is in use; can't reserve {tag} range"
)

if downstream_vlan_table[vlan] is not UNUSED_VLAN:
raise Exception(
f"Downstream VLAN {vlan} is in use; can't reserve {tag} range"
)

# We'll simply assume that both ingress and egress
# ranges are the same.
return ingress_vlans_str

for vlan in common_vlans:
if (
upstream_vlan_table[vlan] is UNUSED_VLAN
Expand All @@ -946,7 +987,8 @@ def _find_common_vlan_on_link(
return vlan

self._logger.warning(
f"No common VLAN found between {domain} and {next_domain} for ports {upstream_egress} and {downstream_ingress}"
f"No common VLAN found between {domain} and {next_domain} "
f"for ports {upstream_egress} and {downstream_ingress}"
)
return None

Expand Down

0 comments on commit e7c7715

Please sign in to comment.