diff --git a/cosmo/l2vpnhelpertypes.py b/cosmo/l2vpnhelpertypes.py index 66b428e..a3bbe3e 100644 --- a/cosmo/l2vpnhelpertypes.py +++ b/cosmo/l2vpnhelpertypes.py @@ -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 @@ -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 @@ -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" @@ -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] diff --git a/cosmo/routerl2vpnvisitor.py b/cosmo/routerl2vpnvisitor.py index 52d6221..2eaebe7 100644 --- a/cosmo/routerl2vpnvisitor.py +++ b/cosmo/routerl2vpnvisitor.py @@ -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()}: " @@ -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): diff --git a/cosmo/tests/test_case_local_l2x.yaml b/cosmo/tests/test_case_local_l2x.yaml index 1ec8112..6890023 100644 --- a/cosmo/tests/test_case_local_l2x.yaml +++ b/cosmo/tests/test_case_local_l2x.yaml @@ -102,7 +102,7 @@ l2vpn_list: - id: '53' __typename: L2VPNType identifier: 12345 - name: 'WAN: L2X_CLIENT9372' + name: 'WAN: L2X' terminations: - assigned_object: __typename: InterfaceType diff --git a/cosmo/tests/test_serializer.py b/cosmo/tests/test_serializer.py index 7823e39..46ca148 100644 --- a/cosmo/tests/test_serializer.py +++ b/cosmo/tests/test_serializer.py @@ -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( { @@ -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"]