From 07dc92f65eb887dab2f57b11ed2fbc1b66ae888e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 27 Aug 2024 17:30:03 +0200 Subject: [PATCH] Remove Dangling* classes as they don't really do anything --- .../models/neutron/l3/firewall.py | 41 ------------------- asr1k_neutron_l3/models/neutron/l3/router.py | 26 ++++++------ 2 files changed, 13 insertions(+), 54 deletions(-) diff --git a/asr1k_neutron_l3/models/neutron/l3/firewall.py b/asr1k_neutron_l3/models/neutron/l3/firewall.py index 935b4482..6d3c0025 100644 --- a/asr1k_neutron_l3/models/neutron/l3/firewall.py +++ b/asr1k_neutron_l3/models/neutron/l3/firewall.py @@ -121,12 +121,6 @@ def _rest_definition(self): return ncServicePolicy(id=self.id, type='inspect', classes=classes) -class DanglingServicePolicy(ServicePolicy): - - def update(self): - return self.delete() - - class FirewallZoneObject(base.Base): PREFIX = None @@ -159,12 +153,6 @@ def _rest_definition(self): return ncZone(id=self.id) -class DanglingZone(Zone): - - def update(self): - return self.delete() - - class ZonePair(FirewallZoneObject): PREFIX = const.FWAAS_ZONE_PAIR_PREFIX @@ -198,16 +186,6 @@ def __init__(self, router_id: str, policy_id: Optional[str] = None): super().__init__(router_id, self.source, self.destination, policy_id) -class DanglingZonePairExtEgress(ZonePairExtEgress): - - def __init__(self, router_id: str): - super().__init__(router_id) - self.policy_id = None - - def update(self): - return self.delete() - - class ZonePairExtIngress(ZonePair): PREFIX = const.FWAAS_ZONE_PAIR_EXT_INGRESS_PREFIX @@ -218,16 +196,6 @@ def __init__(self, router_id: str, policy_id: Optional[str] = None): super().__init__(router_id, self.source, self.destination, policy_id) -class DanglingZonePairExtIngress(ZonePairExtIngress): - - def __init__(self, router_id: str): - super().__init__(router_id) - self.policy_id = None - - def update(self): - return self.delete() - - class FirewallVrfPolicer(base.Base): DEFAULT_PARAMETER_MAP = const.FWAAS_DEFAULT_PARAMETER_MAP @@ -249,12 +217,3 @@ def id(self) -> str: @property def _rest_definition(self) -> ncParameterMapInspectGlobalVrf: return ncParameterMapInspectGlobalVrf(vrf=self.vrf, parameter_map=self.parameter_map) - - -class DanglingFirewallVrfPolicer(FirewallVrfPolicer): - - def __init__(self, router_id: str, parameter_map=None) -> None: - super().__init__(router_id, parameter_map) - - def update(self): - return self.delete() diff --git a/asr1k_neutron_l3/models/neutron/l3/router.py b/asr1k_neutron_l3/models/neutron/l3/router.py index a63172f4..55d9e6f8 100644 --- a/asr1k_neutron_l3/models/neutron/l3/router.py +++ b/asr1k_neutron_l3/models/neutron/l3/router.py @@ -422,12 +422,12 @@ def _update(self): for obj in self.fwaas_conf: results.append(obj.update()) - # If there are no external policies, we can create dangling objects which will trigger the deletion + # If there are no external policies, we can create dangling objects which will and call delete if not self.fwaas_external_policies['ingress'] and not self.fwaas_external_policies['egress']: - results.append(firewall.DanglingZonePairExtIngress(self.router_id).update()) - results.append(firewall.DanglingZonePairExtEgress(self.router_id).update()) - results.append(firewall.DanglingFirewallVrfPolicer(self.router_id).update()) - results.append(firewall.DanglingZone(self.router_id).update()) + results.append(firewall.ZonePairExtIngress(self.router_id).delete()) + results.append(firewall.ZonePairExtEgress(self.router_id).delete()) + results.append(firewall.FirewallVrfPolicer(self.router_id).delete()) + results.append(firewall.Zone(self.router_id).delete()) if self.pbr_acl: results.append(self.pbr_acl.update()) @@ -496,10 +496,10 @@ def _delete(self): for interface in self.interfaces.all_interfaces: results.append(interface.delete()) - results.append(firewall.DanglingZonePairExtIngress(self.router_id).delete()) - results.append(firewall.DanglingZonePairExtEgress(self.router_id).delete()) - results.append(firewall.DanglingFirewallVrfPolicer(self.router_id).delete()) - results.append(firewall.DanglingZone(self.router_id).delete()) + results.append(firewall.ZonePairExtIngress(self.router_id).delete()) + results.append(firewall.ZonePairExtEgress(self.router_id).delete()) + results.append(firewall.FirewallVrfPolicer(self.router_id).delete()) + results.append(firewall.Zone(self.router_id).delete()) results.append(self.vrf.delete()) @@ -578,10 +578,10 @@ def diff(self): diff_results[obj.id] = d.to_dict() if not self.fwaas_external_policies['ingress'] and not self.fwaas_external_policies['egress']: - for obj in [firewall.DanglingZonePairExtIngress(self.router_id), - firewall.DanglingZonePairExtEgress(self.router_id), - firewall.DanglingFirewallVrfPolicer(self.router_id), - firewall.DanglingZone(self.router_id)]: + for obj in [firewall.ZonePairExtIngress(self.router_id), + firewall.ZonePairExtEgress(self.router_id), + firewall.FirewallVrfPolicer(self.router_id), + firewall.Zone(self.router_id)]: d = obj.diff(should_be_none=True) if not d.valid: diff_results[obj.id] = d.to_dict()