Skip to content
Closed
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
17 changes: 0 additions & 17 deletions cosmo/l2vpnhelpertypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ def isValidNumberOfTerminations(self, i: int):
def getInvalidNumberOfTerminationsErrorMessage(cls, i: int):
return f"{cls.getNetboxTypeName().upper()}: {i} is not a valid number of terminations, ignoring..."

@abstractmethod
def isValidRawName(self, name: str) -> bool:
pass

def needsL2VPNIdentifierAsMandatory(self) -> bool:
return False

Expand Down Expand Up @@ -236,9 +232,6 @@ def getInvalidNumberOfTerminationsErrorMessage(cls, i: int):
class AbstractEPLEVPLL2VpnTypeCommon(
AbstractL2VpnTypeTerminationVisitor, metaclass=ABCMeta
):
def isValidRawName(self, name: str) -> bool:
return name.startswith("WAN: L2X_")

def localInterfaceValidationTemplateMethod(self, local: InterfaceType):
pass

Expand Down Expand Up @@ -421,10 +414,6 @@ def processInterfaceTypeTermination(self, o: InterfaceType) -> dict | None:
class VPWSL2VpnTypeTerminationVisitor(
AbstractVPWSEVPNVPWSVpnTypeCommon, AbstractP2PL2VpnTypeTerminationVisitor
):
def isValidRawName(self, name: str) -> bool:
# VPWS is legacy for us, we do not care about the naming scheme
return bool(len(name))

@staticmethod
def getNetboxTypeName() -> str:
return "vpws"
Expand All @@ -433,18 +422,12 @@ def getNetboxTypeName() -> str:
class EVPNVPWSVpnTypeTerminationVisitor(
AbstractVPWSEVPNVPWSVpnTypeCommon, AbstractP2PL2VpnTypeTerminationVisitor
):
def isValidRawName(self, name: str) -> bool:
return name.startswith("WAN: L2X_")

@staticmethod
def getNetboxTypeName() -> str:
return "evpn-vpws"


class MPLSEVPNL2VpnTypeTerminationVisitor(AbstractAnyToAnyL2VpnTypeTerminationVisitor):
def isValidRawName(self, name: str) -> bool:
return name.startswith("WAN: VS_")

@staticmethod
def getSupportedEncapTraits() -> list[type[AbstractEncapCapability]]:
return [VlanBridgeEncapCapability]
Expand Down
5 changes: 2 additions & 3 deletions cosmo/routerl2vpnvisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def isCompliantWANL2VPN(self, o: L2VPNType):
terminations = o.getTerminations()
identifier = o.getIdentifier()
l2vpn_type = self.getL2VpnTypeTerminationObjectFrom(o)
if not l2vpn_type.isValidRawName(o.getName()):
raise L2VPNSerializationError(f'L2VPN "{o.getName()}" is incorrectly named')
if not l2vpn_type.isValidNumberOfTerminations(len(terminations)):
raise L2VPNSerializationError(
f"for {o.getName()}: "
Expand All @@ -73,7 +71,8 @@ def isCompliantWANL2VPN(self, o: L2VPNType):

@accept.register
def _(self, o: L2VPNType):
self.isCompliantWANL2VPN(o)
if o.getName().startswith("WAN"):
self.isCompliantWANL2VPN(o)


class RouterL2VPNExporterVisitor(AbstractL2VPNVisitor):
Expand Down
2 changes: 1 addition & 1 deletion cosmo/tests/test_case_local_l2x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ l2vpn_list:
- id: '53'
__typename: L2VPNType
identifier: 12345
name: 'WAN: L2X_CLIENT9372'
name: 'WAN: L2X'
terminations:
- assigned_object:
__typename: InterfaceType
Expand Down
31 changes: 2 additions & 29 deletions cosmo/tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,6 @@ def test_l2vpn_errors(capsys):

template = _yaml_load("./test_case_l2x_err_template.yaml")

evpn_vpws_incorrect_name = copy.deepcopy(template)
evpn_vpws_incorrect_name["l2vpn_list"].append(
{
"__typename": "L2VPNType",
"id": "53",
"identifier": 123456,
"name": "missing WAN: prefix",
"type": "EVPN-VPWS",
"terminations": [
{
"__typename": "L2VPNTerminationType",
"assigned_object": {
"__typename": "InterfaceType",
},
},
{
"__typename": "L2VPNTerminationType",
"assigned_object": {
"__typename": "InterfaceType",
},
},
],
}
)
with pytest.raises(DeviceSerializationError, match="is incorrectly named"):
serialize(evpn_vpws_incorrect_name)

vpws_incorrect_terminations = copy.deepcopy(template)
vpws_incorrect_terminations["l2vpn_list"].append(
{
Expand Down Expand Up @@ -498,10 +471,10 @@ def test_router_case_local_l2x():

assert len(d["l2circuits"]) == 1

l2c = d["l2circuits"]["L2X_CLIENT9372"]
l2c = d["l2circuits"]["L2X"]

assert len(l2c["interfaces"]) == 2
assert l2c["description"] == "EVPL: L2X_CLIENT9372 via TEST0001"
assert l2c["description"] == "EVPL: L2X via TEST0001"

assert (
l2c["interfaces"]["ifp-0/0/4.7"]["local_label"]
Expand Down