Skip to content

Commit

Permalink
[pfsense_interface] Do not allow removal of interfaces that are part …
Browse files Browse the repository at this point in the history
…of an interface group
  • Loading branch information
opoplawski committed Jan 4, 2024
1 parent 85f342c commit 4226fd2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions plugins/module_utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,18 @@ def _pre_remove_target_elt(self):
""" processing before removing elt """
self.obj['if'] = self.target_elt.find('if').text

self._remove_all_separators(self.target_elt.tag)
self._remove_all_rules(self.target_elt.tag)

self.setup_interface_pre_cmds += "interface_bring_down('{0}');\n".format(self.target_elt.tag)
self.result['ifname'] = self.target_elt.tag
ifname = self.target_elt.tag
for ifgroup_elt in self.pfsense.ifgroups.findall("ifgroupentry"):
members = ifgroup_elt.find('members').text.split()
if ifname in members:
self.module.fail_json(msg='The interface is part of the group {0}. Please remove it from the group first.'.format(
ifgroup_elt.find('ifname').text))

self._remove_all_separators(ifname)
self._remove_all_rules(ifname)

self.setup_interface_pre_cmds += "interface_bring_down('{0}');\n".format(ifname)
self.result['ifname'] = ifname

def _remove_all_rules(self, interface):
""" delete all interface rules """
Expand Down

0 comments on commit 4226fd2

Please sign in to comment.