Skip to content

Commit

Permalink
[pfsense_openvpn_server] Do not allow removal of an instance with an …
Browse files Browse the repository at this point in the history
…interface assignment
  • Loading branch information
opoplawski committed Jan 4, 2024
1 parent 834f13b commit 1f30825
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/module_utils/openvpn_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ def _find_target(self):
def _pre_remove_target_elt(self):
""" processing before removing elt """
self.diff['before'] = self.pfsense.element_to_dict(self.target_elt)

if len(self.pfsense.interfaces.findall("*[if='ovpns{0}']".format(self.diff['before']['vpnid']))) > 0:
self.module.fail_json(msg='Cannot delete the OpenVPN instance while the interface ovpns{0} is assigned. Remove the interface assignment first.'
.format(self.diff['before']['vpnid']))

self.result['vpnid'] = int(self.diff['before']['vpnid'])
self.command_output = self.pfsense.phpshell(OPENVPN_SERVER_PHP_COMMAND_DEL.format(idx=self.idx))

Expand Down

0 comments on commit 1f30825

Please sign in to comment.