Skip to content

Commit

Permalink
409 for reserving existing vlan
Browse files Browse the repository at this point in the history
  • Loading branch information
YufengXin committed Jan 17, 2025
1 parent 3a92529 commit 8082b9f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sdx_pce/topology/temanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,11 @@ def _reserve_vlan_breakdown(
# segment["ingress_vlan"] = ingress_vlan
# segment["egress_vlan"] = egress_vlan
# upstream_o_vlan = egress_vlan
tag_type = 0 if type(ingress_vlan) is str else 1
tag_type = 0 if ingress_vlan == "untagged" else 1
port_a = VlanTaggedPort(
VlanTag(value=ingress_vlan, tag_type=tag_type), port_id=ingress_port_id
)
tag_type = 0 if type(egress_vlan) is str else 1
tag_type = 0 if egress_vlan == "untagged" else 1
port_z = VlanTaggedPort(
VlanTag(value=egress_vlan, tag_type=tag_type), port_id=egress_port_id
)
Expand Down Expand Up @@ -1174,7 +1174,10 @@ def _reserve_vlan(
# Check if all VLANs in the range are available.
for vlan in vlans:
if vlan_table[vlan] is not UNUSED_VLAN:
raise Exception(f"VLAN {vlan} is in use; can't reserve {tag} range")
raise TEError(
f"VLAN {vlan} is in use; can't reserve {tag}",
409,
)

# Mark range in use.
for vlan in vlans:
Expand All @@ -1194,7 +1197,10 @@ def _reserve_vlan(
available_tag = tag
else:
self._logger.error(f"VLAN {tag} is in use by {vlan_table[tag]}")
return None
raise TEError(
f"VLAN {vlan} is in use; can't reserve {tag}",
409,
)
else:
self._logger.error(f"VLAN {tag} is not present in the table")
return None
Expand Down

0 comments on commit 8082b9f

Please sign in to comment.