Skip to content

Commit

Permalink
Remove Dangling* classes as they don't really do anything
Browse files Browse the repository at this point in the history
  • Loading branch information
swagner-de committed Sep 3, 2024
1 parent 64f5eba commit 07dc92f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 54 deletions.
41 changes: 0 additions & 41 deletions asr1k_neutron_l3/models/neutron/l3/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
26 changes: 13 additions & 13 deletions asr1k_neutron_l3/models/neutron/l3/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 07dc92f

Please sign in to comment.